Click to See Complete Forum and Search --> : Dumb Question


webdev1
07-24-2003, 02:44 PM
Ok, I apologize in advance for being brain dead today but here is my dilemna. How do I say the selected field of a dropdown box? I was thinking it should be something like document.forms.formname.fieldname.value.selected but that doesn't seem to work. I also tried just .value and just .selected and neither seem to be correct. Any ideas? Thanks a million!

Jona
07-24-2003, 03:02 PM
document.formName.selectName.options[document.formName.selectName.options.selectedIndex].index


Index will give you the number that the selected option is, and if you change .index to .value you'll get the selected option's value.

[J]ona

Khalid Ali
07-24-2003, 03:02 PM
document.formName.listboxName.options[document.formName.listboxName.selectedIndex].value

webdev1
07-24-2003, 03:03 PM
Thanks! I actually got it working seconds before getting your post.

Jona
07-24-2003, 03:07 PM
Originally posted by Khalid Ali
document.formName.listboxName.options[document.formName.listboxName.selectedIndex].value

Tsk, tsk... Beatcha' Khalid! :D

lol...

[J]ona