Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

repopulating drop down menus

Status
Not open for further replies.

rogerhadden

Technical User
Nov 14, 2007
2
GB
Using the script below, I am trying to repopulate some drop down menus - depending on a previous choice. - the repopulate bit works, but I am unable to select any of the items from the new menus???

function upDate(){
if(document.choices.Form.value=="LM granules, Practitioners Only"){
document.choices.Size.length=0
document.choices.Size.options[0]=new Option("2g LM-Granules £4.75","2g LM-Granules £4.75")
}

if(document.choices.Form.value=="LM liquid"){
document.choices.Size.length=0
document.choices.Size.options[0]=new Option("15mlm - teat dropper (10% alc)(£4.20)","15mlm - teat dropper (10% alc)(£4.20)")
document.choices.Size.options[1]=new Option("30mlm - teat dropper (10% alc)(£4.40)" ,"30mlm - teat dropper (10% alc)(£4.40)")
document.choices.Size.options[2]=new Option("50mlm - teat dropper (10% alc)(£4.50)","50mlm - teat dropper (10% alc)(£4.50)")
document.choices.Size.options[3]=new Option("100mlm - teat dropper (10% alc)(£4.75)","100mlm - teat dropper (10% alc)(£4.75)")
document.choices.Size.options[4]=new Option("150mlm - teat dropper (10% alc)(£5.00)","150mlm - teat dropper (10% alc)(£5.00)")


}
if(document.choices.Form.value=="Tablets"||document.choices.Form.value=="Pills"){
document.choices.Size.length=0
document.choices.Size.options[0]=new Option("4g - Tablets/Pills(£3.95)","")
document.choices.Size.options[1]=new Option("8g - Tablets/Pills (£4.75)","")
document.choices.Size.options[2]=new Option("14g - Tablets/Pills (£5.30)","")
document.choices.Size.options[3]=new Option("28g - Tablets/Pills(£6.15)","")
document.choices.Size.options[4]=new Option("40g - Tablets/Pills(£7.40)","")

}
if(document.choices.Form.value=="Soft Tablets"||document.choices.Form.value=="Granules"){
document.choices.Size.length=0
document.choices.Size.options[0]=new Option("4g - Soft tabs/Granules(£4.10)","")
document.choices.Size.options[1]=new Option("8g - Soft tabs/Granules(£4.90)","")
document.choices.Size.options[2]=new Option("14g - Soft tabs/Granules(£5.50)","")
document.choices.Size.options[3]=new Option("28g - Soft tabs/Granules (£6.45)","")
document.choices.Size.options[4]=new Option("40g - Soft tabs/Granules(£7.75)","")

}
if(document.choices.Form.value=="Medicating Potency"){
document.choices.Size.length=0
document.choices.Size.options[0]=new Option("3.5ml - Medicating Potency(£4.40)","")
document.choices.Size.options[1]=new Option("7ml - Medicating Potency(£6.40)","")
document.choices.Size.options[2]=new Option("14ml - Medicating Potency(£8.20)","")

}
if(document.choices.Form.value=="Oral Liquid"){
document.choices.Size.length=0
document.choices.Size.options[0]=new Option("5ml - Oral Liquid(£4.15)","5ml - Oral Liquid(£4.15)")
document.choices.Size.options[1]=new Option("10ml - Oral Liquid(£4.95)","10ml - Oral Liquid(£4.95)")
document.choices.Size.options[2]=new Option("10ml - Oral Liquid(£5.20)","10ml - Oral Liquid(£5.20)")
document.choices.Size.options[3]=new Option("15ml - Oral Liquid(£5.50)","15ml - Oral Liquid(£5.50)")
document.choices.Size.options[4]=new Option("30ml - Oral Liquid(£6.35)","30ml - Oral Liquid(£6.35)")
document.choices.Size.options[5]=new Option("50ml - Oral Liquid(£8.25)","50ml - Oral Liquid(£8.25)")
document.choices.Size.options[6]=new Option("100ml - Oral Liquid(£11.60)","100ml - Oral Liquid(£11.60)")


}
}
 
When you say you are "unable to select any of the items", do you mean that:

- The list box is unclickable?
- The list box is clickable but the options are not?
- The list box and options are clickable, but the list box does not change to your clicked option?
- The list box and options are clickable, but the form does not post the chosen value?
- Something else?

Also, have you tried multiple browsers? If so, does the problem happen in all of them?

Either way, check out faq216-6294 for more on dynamic listboxes.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan

The problem i find is that the second drop down will re-populate with the code, the options will highlight, but the option selected does not appear in the box.

Your link looks good - will try and adapt that to my needs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top