如果没有选择使用服务器端编程(例如PHP)的选项,则可以使用查询字符串或GET参数。
在表单中,添加一个
method="GET"属性:
<form action="display.html" method="GET"> <input type="text" name="serialNumber" /> <input type="submit" value="Submit" /></form>
当他们提交此表单时,会将用户定向到包含该
serialNumber值作为参数的地址。就像是:
http://www.example.com/display.html?serialNumber=XYZ
然后,您应该能够
serialNumber使用以下
window.location.search值从Javascript
解析查询字符串(其中将包含参数值):
// from display.htmldocument.getElementById("write").innerHTML = window.location.search; // you will have to parse // the query string to extract the // parameter you need


