用 document.getElementById("xxxx").value="somethind"; xxxx不显示somethind

pujitan978 2017-04-16 09:08:20
点击画面的select,更新入力框的内容,一直不能显示 somethind,一直空白。但是alert得内容是"somethind";
这个动作是在弹出画面做的。

function test(value){
document.getElementById("dmmonye1").value="somethind";
alert(document.getElementById("dmmonye1").value);

}


下面是弹出画面代码,用的是 模态框
<div class="modal fade" id="myModal1_{$a.activity_id}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
<div class="modal-dialog">
<div class="modal-content">

<div class="modal-body" style="margin-top:50px;">

<div style="width: 800px;text-align:center;height:30px">
<label style="color: #fff;font-size: 14px;width:105px;height:30px;margin-left:0px;font-family: '微软雅黑';">选择申请:</label>
<if condition="$a.handsel_id neq '' ">
<select name="handsel_id" id="handsel_id_{$a.activity_id}" style="margin-left:0;width:200px;height:30px;" onchange="test(this)"> >


<foreach name="a['handsel']" item='d'>
<option value="{$d.handsel_id}_{$d.money}_{$d.dmmoney}" >{$d.handsel_name}----{$d.money}</option>
</foreach>
</select>
<else/>
<input type="text" name="money" value="" style="margin-left:0px;width:200px;height:30px"/>
</if>
<label style="color: #fff;font-size: 14px;width:43px;height:29px;margin-left:20px;font-family: '微软雅黑';">tianqi:</label>
<input type="text" id="money1" name="money" style="margin-left:0px;width:100px;height:30px;"/>
<label style="color: #fff;font-size: 14px;width:55px;height:29px;margin-left:20px;font-family: '微软雅黑';">aaaaa:</label>
<input type="text" id="dmmonye1" name="money" value="" style="margin-left:0px;width:100px;height:30px;"/>

</div>

</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>

...全文
253 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_24685299 2017-04-26
  • 打赏
  • 举报
回复
HTML<select>下拉框中,可以通过设定一个空值来使开始显示的是空白(如设置第一行<option value="kongbai"></option> 为空)
  • 打赏
  • 举报
回复
检查dom,你页面肯定存在2个以上id为dmmonye1的对象,document.getElementById("dmmonye1")只会返回第一个出现的dom对象

87,989

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧