如何将表格值放入弹出框中?它输出“未定义”而不是选定的表值
<script>
function conf () {
var x, res, y;
res = document.getElementById('t').onclick
if(document.formxml.num1.value >= 2) {
var r = confirm("Reserve for " + document.formxml.num1.value + " persons in "+document.formxml.res. + "?");
} else if(document.formxml.num1.value == 1) {
var r = confirm("Reserve for " + document.formxml.num1.value + " person in " + document.formxml.res. + "?");
} else if(document.formxml.num1.value < 0) {
var r = confirm("You cannot input a negative number!");
}
if(r == true) {
x = "";
location.href = 'res3.html'
} else if(r == false) {
x = "";
}
}
</script>
</head>
<body>
<style type="text/css">
.txt {width:50px;}
</style>
<form action="" method="get" name="formxml">
For how many persons?
<input type="text" name="num1" value="" class="txt" id="num1" maxlength="2">
<input type="button" value="Table 1" id="t" name="res" onclick="conf();">
<input type="button" value="Table 3" id="t" name="res" onclick="conf();">
</form>
我不知道接下来会发生什么var r=confirm("Reserve for "+document.formxml.num1.value+" person in "+document.formxml.res.+"?");