| | |
un-disable dropdown box
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 62
Reputation:
Solved Threads: 6
Hi I have some code here that fills a dropdown box from an array depending on what is selected in another dropdown box. One of them is disabled, and i would like to stop that once an option has been selected.
This is the Javascript:
and the html
if anyone could give me a way to remove the disabled part on the second box once an option in the first box has been selected I would be grateful.
Thanks
This is the Javascript:
javascript Syntax (Toggle Plain Text)
function fillStates(opt){ s=document.f.states.options s.length=stateNames[opt].length for(i=0;i<s.length;i++){ s[i].value=stateNames[opt][i] s[i].text=stateNames[opt][i] } document.f.states.selectedIndex=0 }
and the html
html Syntax (Toggle Plain Text)
<form name="f"> <select name=countries onChange="fillStates(this.options[this.selectedIndex].value)"> <? echo $optionc; ?> </select> <select name=states disabled="disabled"> <option>Choose a country first</option> </select> </form>
if anyone could give me a way to remove the disabled part on the second box once an option in the first box has been selected I would be grateful.
Thanks
<listbox>.disabled = false
Last edited by ShawnCplus; Jan 21st, 2008 at 3:59 pm.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
•
•
Join Date: Jan 2008
Posts: 62
Reputation:
Solved Threads: 6
thanks guys, this is how i fixed it:
javascript Syntax (Toggle Plain Text)
if (opt=="none"){document.f.states.disabled=true} else {document.f.states.disabled=false}
Last edited by hooray; Jan 21st, 2008 at 7:08 pm.
•
•
•
•
That won't work. The selectbox doesn't have an ID, set the ID to states then do the above for it to work.
<select name="states" id="states">
Otherwise you would have to use the getElementsByName() method to get all the elements with the name "states".
> Otherwise you would have to use the getElementsByName() method to get all the elements
> with the name "states".
Or simply
> with the name "states".
Or simply
document.forms[0].elements["states"].disabled = false; which is the correct way of handling form elements. I don't accept change; I don't deserve to live.
Sacrifice is a painful, pure and beautiful thing.
Dammit, Jones, What the Hell Are Knoll Pointers?!
Sacrifice is a painful, pure and beautiful thing.
Dammit, Jones, What the Hell Are Knoll Pointers?!
![]() |
Similar Threads
- Recent changes (DaniWeb Community Feedback)
- Shut Down And Saving Your Settings (Windows NT / 2000 / XP)
- Pop-up "Messenger Service" HELP! Please. (Viruses, Spyware and other Nasties)
- Pop up ads to buy Spyware and Homepage changed. (Viruses, Spyware and other Nasties)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Works in FF, not in IE7
- Next Thread: Need to create an Event Calendar for company website
Views: 2776 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
8 ad ajax ajaxcode animate api array asp.net autocomplete autoplay box boxes bug catch close content css cursor date db dependent design div dom download draganddrop dynamic element embed error event events explorer explosion file firefox firehose flash focus font form function gears google gwt hangman hide hijack html ie7 iframe image image() internet internet-explorer java javascript javascripts jawascriptruntimeerror jquery js libcurl lists load maps matrixcaptcha modal mysql onclick onmouseover parameters pass photo php player position post prototype resize scroll scrubber search select show size sorting sources text textarea toggle tooltip twitter unicode validation variables web webkit window windowsxp xml






