checking values in javascript
how can i check a value in javascript. for example:
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Colleges","Colleges");
document.formname.subcategory.options[2]=new Option("Institutes","Institutes");
document.formname.sub开发者_如何学运维category.options[3]=new Option("Schools","Schools");
document.formname.subcategory.options[4]=new Option("Tuitions","Tuitions");
document.formname.subcategory.options[5]=new Option("Universities","Universities");
how can i check the value if it's "Colleges" or "Schools", etc.? is it like this?
document.formname.subcategory.options.value == "Universities"
or like this?
document.formname.subcategory.options.value == 5
The first one:
document.formname.subcategory.options.value == "Universities";
value is the string that will be sent to the server when the form is submitted, so you're comparing a string with a string. :D
精彩评论