[英]getting dynamic values from html form to javascript
I am using javascript to add element dynamically. 我正在使用javascript动态添加元素。 Here count is defined and increasing by one
此处定义了计数,并增加了1
<span style="margin-left:10px;">File Type : <select name="select_type_'+count+'" >
<option value="select">Select</option></span>
I using an another javascript function to get the value of select_type_'+count+' by using 我使用另一个javascript函数通过使用来获取select_type _'+ count +'的值
var temp=parseInt((document.submission.select_type_+i.value));
alert(temp);
here var i
is defined and incrementing 此处定义了var
i
并递增
but i am getting NaN
value .how to solve this?thanks in advance 但是我正在获得
NaN
值。如何解决这个问题?
Try this instead: 尝试以下方法:
var temp=parseInt((document.submission['select_type_'+i].value));
alert(temp);
The JavaScript parser interprets your original code as document.submission.select_type
plus i.value
. JavaScript解析器将您的原始代码解释为
document.submission.select_type
加上i.value
。 Since neither document.submission.select_type
nor i.value
are defined, you're getting NaN
from parseInt
. 由于未定义
document.submission.select_type
和i.value
,因此您将从parseInt
获得NaN
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.