如何用javascript取某个文本框的值?

来源:百度知道 编辑:UC知道 时间:2024/05/09 04:15:21
<input type="text" name="DiyPage" size="15" />
<input type="button" onclick="window.location.href='?topage='+document.getElementByID("DiyPage").value" value="转到"/>
我用这种方法,老是提示错误,为什么

<input type="text" id="DiyPage" name="DiyPage" size="15" />
<input type="button" onclick="window.location = '?topage=' +document.getElementById('DiyPage').value" value="转到"/>

我给改好了
<input type="text" id="DiyPage" size="15" />
<input type="button" onclick="aa()" value="转到"/>
<script>
function aa()
{
var oldlocation = window.location;
alert(oldlocation);
oldlocation = oldlocation+"?topage="+document.getElementById("DiyPage").value;
alert(oldlocation);
window.location = oldlocation;
}
</script>