Forum Moderators: open
Here is what I'm trying to achieve :
- When the page loads, a Javascript call to the DOM disabled Property disables a select menu identified by its ID (let's call it SELECT A).
- When another select menu (let's call it SELECT B) is modified, a Javascript function evaluates the value it returns. If some specific value is returned, it then uses the DOM disabled Property to set SELECT A to enable.
So far I've been able to get and display the value sent by SELECT B when modified, with the following code :
QuickForm code :
$form->addElement('select', 'selectb', 'SELECT B :', $selectb_options, array('onchange' => "check(this.options[this.selectedIndex].value)"));
Javascript code :
function check(the_value) { alert(the_value); }
My problem is I can't get Quickform to actually use Javascript to disable SELECT A when loading.
I have the following QuickForm code to generate SELECT A :
$form->addElement('select', 'selecta', 'SELECT A :', $selecta_options, array('id' => 'selecta'));
I have confirmed that the HTML generated is proper :
<select id="selecta" name="selecta">
But I'm unable to have it disabled, even with the following code in the page's headers :
<script language="javascript" type="text/javascript">
document.getElementById("selecta").disabled=true;
</script>
So, obviously, I'm stuck and can't go forward implementing all the nifty things that come after this (the condition upon the value returned by SELECT B and the call to either the enable() or disable() functions I intend to write).
Anybody would have an idea why this is not working? A simple select construct works fine with the DOM Disable, like here : [w3schools.com ] so I suspect QuickForm to be the problem here... Maybe an "onload" to the form's init? (how?)?
Thanks guys!