aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Enable the one drop down at a time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Enable the one drop down at a time" Watch "Enable the one drop down at a time" New topic
Author

Enable the one drop down at a time

Amitkumar Fulambarkar
Greenhorn

Joined: Sep 17, 2008
Posts: 29
Hi,

I want to keep the one drop down active at a time in the form. When the page loads, one DD will be active and other will remain disabled. When I click on Disabled DD, it will get active while and the first DD which was enabled will turn to Disabled and vice a versa. So that user can submit the value for one DD only.

Can someone please help me with the code for this?

Below is the code I tried. I am calling this method on onblur and onfocus event of the DD component. However it doesn't work as expected.




Thanks
Amit
Komal Renu
Ranch Hand

Joined: Jul 21, 2011
Posts: 51
Hi Amit,

Change your javascript function as under:


Hope this helps.

Thanks and Regards,
-------------------------------------------------------------------------------------
Komal Renu | krenu@infocepts.com | www.infocepts.com
-------------------------------------------------------------------------------------
Amitkumar Fulambarkar
Greenhorn

Joined: Sep 17, 2008
Posts: 29
Thanks for your reply Renu!

I had tried this option already. With the following code, when the page loads first time, both the DDs are enabled, that is fine. When I click one dropdown, other one get disabled. However, I also want it working working vice-versa.

It means if the user changes his mind to change the select option, he should be able to enable the disabled drop down and this time first DD will get disabled then.

So if we quick DD1, DD2 will disable. If we again click DD2, it will enable back and disable DD1.
Is it possible?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
When the dropdown is disabled, how do you expect it to get focus? You can not focus it.

Eric
Komal Renu
Ranch Hand

Joined: Jul 21, 2011
Posts: 51
Yes, what Eric says is correct and hence your javascript is not working.
I've created a small POC.
On page load, both multiboxes are enabled. The moment mouse moves over a particular multibox, the other one gets disbaled. This will work only for the first time when the page loads and both are enabled.

After that the user can click on the link to enable the corresponding multibox.

Here's the code



Try this out and do let me know if any additional help is required.

Thanks and Regards,
-------------------------------------------------------------------------------------
Komal Renu | krenu@infocepts.com | www.infocepts.com
-------------------------------------------------------------------------------------
Amitkumar Fulambarkar
Greenhorn

Joined: Sep 17, 2008
Posts: 29
This is awesome Renu. This is working perfectly fine.

I was thinking not to add additional component to just handle the enable/disable logic, hence I didn't think in that direction. I was guessing if there is any way to execute the event on disabled component that I might not know. And this is the right forum to get the experts advice.

Thank you for your prompt help on this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enable the one drop down at a time