homepage Welcome to WebmasterWorld Guest from 50.17.162.174
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
QuickForm and the DOM disabled Property
Can they work together?
jerome




msg:3563099
 6:35 pm on Jan 31, 2008 (gmt 0)

Hi! I'm totally illiterate when it comes to Javascript, and I'm stuck here with trying to use the DOM disabled Property to disable a select within a form generated with PEAR's HTML/Quickform.

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">

and the select works fine.

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!

 

jerome




msg:3564275
 8:48 pm on Feb 1, 2008 (gmt 0)

Ok, just for the record, I found a workaround. I used QuickForm's "hierselect" statement and set it up so that the second select shows a "N/A" value except when the right selection is made within the first select. Then it shows the sub-values. Took a bit of array mingling on the backend, but that's working!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved