点击按钮获得文本框里面的值
<script type=”text/javascript”>
window.onload = function(){
var obtn=document.getElementById(“Button2”);
obtn.onclick = function(){
alert(document.getElementsById(“Text2”).value);
};
}
</script>
<p>用户名:<input id=”Text2″ type=”text” value=”用户名”/><input id=”Button2″ type=”button” value=”获得用户名”/></p>
或者:
<p>用户名:<input id=”Text2″ type=”text” value=”用户名”/><input id=”Button2″ type=”button” value=”获得用户名” onclick=”javascript:alert(document.getElmentById(Text2).value);”/></p