怎么从js中取值

来源:百度知道 编辑:UC知道 时间:2024/05/21 01:50:01
页面是从jsp中的表单提交数据,提交时用onsubmit在脚本中进行了验证,我现在想要在脚本中修改文本框提交的值,然后用这个值传给action,脚本怎么写?

<form action="" method ="post" onsubmit="return check(this)">
<input type="text" id="txtValue">
<input type="submit" value="提交">
</form>
<script>
function(obj){
var text = obj.getElementById("txtValue").value;
alert(text);
return true;
}
</script>

一楼的就是了
document.getElementById("txtValue").value = "修改后的值";