yangyan 发表于 2012-9-19 20:06:59

视图文件中不能获的输入框的值

本帖最后由 yangyan 于 2012-9-19 20:10 编辑

代码:
<input name="password1" id="password1" class="password" type="password" style="position:relative; z-index:12;"value=""/>
<script type="text/javascript">
function set_psw()
{
var password=document.getElementById("password1").value;
alert(password);
}
输入值后,
但是alert出来的值为空 是怎么回事了?

yangyan 发表于 2012-9-20 10:07:02

自己来把问题结了吧 至于为什么在ci视图里我始终不能用document.getElementById().value获取值。我这里用的处理办法是在set_psw()函数调用处改为set_psw(this),函数定义为set_psw(password),里面取值的语句变为password.value.即通过对象来取值
页: [1]
查看完整版本: 视图文件中不能获的输入框的值