Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: dynamic dropdownbox


Message #1 by "Sam Lewitan" <slewitan@e...> on Wed, 28 Nov 2001 16:37:22
--0-479127170-1007029021=:25656
Content-Type: text/plain; charset=us-ascii


 If you have two select elements Select1 and Select2, you get that:
<script>
function fChange()
{
  var oElem;
  if(Select1.options[Select1.selectedIndex].innerText == "Numbers")
  {
    for(i = 0; i < 3; i++)
    {    
       oElem = document.createElement("option");
       oElem.innerText = i + 1;
       Select2.options.add(oElem);
    }
  }
  if(Select1.options[Select1.selectedIndex].innerText == "Letters")
  {
    for(i = 0; i < 3; i++)
    {    
       oElem = document.createElement("option");
       oElem.innerText = String.fromCharCode(65 + i);
       Select2.options.add(oElem);
    }
  }
}
</script>
<select name="Select1" onchange="fChange()">
<option>Numbers</option>
<option>Letters</option>
</select>
<select name="Select2" onchange="alert(Select2.options[Select2.selectedIndex].innerText)">
</select>

Hope it will work! Good luck!

  Sam Lewitan <slewitan@e...> wrote: Dear Everyone,
Hi, I have a dropdown with a set of static options what I want to do is if 
a person selects an option from this box the options should change 
accordingly for example if in dropdown1 he can choose:
Numbers
letters
if he would choose letters the second box would show
A
B
C
Then if he would choose numbers in the first box the second box would show
1
2
3

Thanks everyone for being there,

Sam Lewitan
SLewitan@E...
http://www.EBCpro.com
where EveryBusinessCounts
(xxx)xxx-xxxx  
(Please note new email address)

Read the future with ebooks at B&N
http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid=rn_ebooks


---------------------------------
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

  Return to Index