日期:2014-05-17  浏览次数:20831 次

JSP 页面中一个form中怎么实现根据“select”的值改变”input“的默认字?
JSP 页面中一个form中怎么实现根据“select”的值改变”input“的默认字?

------解决方案--------------------
在input中定义一个id,然后当select改变时(onchange事件)重新给input赋值,比如说:
function setInputValues() {
$("#inputId").val("你想赋的值");
}
注:setInputValues() 是select的onchange方法
<input type="text", id="inputId" value="最开始时的默认值"/>

LZ要的是这种么?

------解决方案--------------------
<select id="selectId" onchange="setValue(this)">
......
</select>
<input id="inputId" type="text" .../>

function setValue(obj){
var inputValue = document.getElementById("inputId");
var value = obj.value;
if(value == ...){
inputValue = ..//根据需求来赋值
}
}