我是 HTML 和 JS 的新手。在同一页面上按下提交后,我想保留文本框和下拉列表的值
<!DOCTYPE html>
<html>
<body>
<script>
function tab()
{
//var t=document.getElementById("test").value;
//document.getElementById("run").value = t;
//t=> You send it to XML
var test_a = document.getElementById("test");
var selectedText = test_a.options[test_a.selectedIndex].text;
document.getElementById("run").value = selectedText;
}
</script>
<form name="myform" action="test.html" method="get">
<select id="test" onchange="tab()">
<option value="-1">--select--</option>
<option value="IN" >INDIA</option>
<option value="BZ">BRAZIL</option>
</select>
<input type="text" name="run" id="run"/>
<input type="Submit">
</form>
</body>
</html>