js显示表单数据
<script language="javascript" type="text/javascript">
function display() {
DispWin = window.open("",'NewWin','toolbar = no,status = no,width = 300,heght = 200')
message = "<ul><li><b>NAME:</b>" + document.form1.yourname.value;
message += "<li><b>ADDRESS:</b>" + document.form1.address.value";
message += "<li><b>PHONE:</b>" + document.form1.phone.value + "</ul>;
DisWin.document.write(message);
}
</script>
<h1 aligen = "center">Form Example</h1>
<form name ="form1">
<p><b>Name:</b> <input type="text" size="20" name="yourname" />
</p>
<p><b>Address:</b><input type="text" size="30" name="address" />
</p>
<p><b>Phone:</b><input type="text" size="15" name="phone" />
</p>
<p><input type="button" value="Display" onclick="display();" /></p>
</form>
以上的代码我是想实现用js在新开的窗口显示通过表单提交的数据...但是却没有什么效果...请问这是为什么呢?
------解决方案--------------------<script language="javascript" type="text/javascript" >
function testDisplay() {
DispWin =window.open("about:blank", 'NewWin', 'toolbar = no,status = no,width = 300,heght = 200 ')
message = " <ul > <li > <b >NAME: </b >" + document.form1.yourname.value;
message += " <li > <b >ADDRESS: </b >" + document.form1.address.value;
message += " <li > <b >PHONE: </b >" + document.form1.phone.value + " </ul >";
DispWin .document.open();
DispWin .document.write(message);
DispWin .document.close();
}
</script>
<h1 aligen = "center" >Form Example </h1>
<form name ="form1">
<p> <b>Name: </b> <input type="text" size="20" name="yourname" />
</p>
<p> <b>Address: </b> <input type="text" size="30" name="address" />
</p>
<p> <b >Phone: </b> <input type="text" size="15" name="phone" />
</p >
<p > <input type="button" value="Display" onclick="testDisplay();" /> </p>
</form>