User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,649 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,865 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

un-disable dropdown box

Join Date: Jan 2008
Location: London, England
Posts: 57
Reputation: hooray is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
hooray hooray is offline Offline
Junior Poster in Training

Help un-disable dropdown box

  #1  
Jan 21st, 2008
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:

  1. function fillStates(opt){
  2. s=document.f.states.options
  3. s.length=stateNames[opt].length
  4. for(i=0;i<s.length;i++){
  5. s[i].value=stateNames[opt][i]
  6. s[i].text=stateNames[opt][i]
  7. }
  8. document.f.states.selectedIndex=0
  9. }

and the html
  1. <form name="f">
  2. <select name=countries onChange="fillStates(this.options[this.selectedIndex].value)">
  3. <? echo $optionc; ?>
  4. </select>
  5. <select name=states disabled="disabled">
  6. <option>Choose a country first</option>
  7. </select>
  8. </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
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 1:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC