如何获得选定的选项的价值 [英] How to get a selected option's value
本文介绍了如何获得选定的选项的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
函数changeDay(monthSelect){
dayVal = day.selected.value;
// secili ayi al
optVal = monthSelect.selected.value;
if(optVal =='Şubat'&& dayVal> 29){
modifyDay(29);
我得到这条错误消息, $ c> dayVal = day.selected.value :
未捕获的TypeError:无法读取属性'值' undefined
我如何达到选定的价值?
解决方案
获取价值的最简单方法:
day.value
它适用于所有浏览器,甚至包括IE 6 b / b
$ b
demo:< $ h $ = $ $ $ $ $ $ $
function changeDay(monthSelect){
dayVal = day.selected.value;
//secili ayi al
optVal = monthSelect.selected.value;
if(optVal=='Şubat' && dayVal > 29){
modifyDay(29);
}
}
I get this error message for the line dayVal = day.selected.value
:
Uncaught TypeError: Cannot read property 'value' of undefined
how can i reach the selected option's value?
解决方案
The simplest way to get the value:
day.value
And it works in all browsers, even IE 6
demo: http://jsfiddle.net/roberkules/8xwhG/
这篇关于如何获得选定的选项的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文