Javascript 通过表单传递JS变量
在下面的Javascript 通过表单传递JS变量,javascript,jquery,html,Javascript,Jquery,Html,在下面的表单中,我需要文档的值。结果[0]。值作为表单变量传递到下一页? 具体而言,此文档。结果[0]。值=totalquestions不正确。长度+值需要作为存储结果.cfm页面上的表单数据进行访问 <form method="POST"><div align="center"><center><p> <script> var wrong=0 for (e=0;e<=2;e++) document.result[e]
表单
中,我需要文档的值。结果[0]。值
作为表单变量传递到下一页?
具体而言,此文档。结果[0]。值=totalquestions不正确。长度+值
需要作为存储结果.cfm
页面上的表单数据进行访问
<form method="POST"><div
align="center"><center><p>
<script>
var wrong=0
for (e=0;e<=2;e++)
document.result[e].value=""
var results=document.cookie.split(";")
for (n=0;n<=results.length-1;n++){
if (results[n].charAt(1)=='q')
parse=n
}
var incorrect=results[parse].split("=")
incorrect=incorrect[1].split("/")
if (incorrect[incorrect.length-1]=='b')
incorrect=""
document.result[0].value=totalquestions-incorrect.length+" out of "+totalquestions
document.result[2].value=(totalquestions-incorrect.length)/totalquestions*100+"%"
for (temp=0;temp<incorrect.length;temp++)
document.result[1].value+=incorrect[temp]+", "
</script>
<input type="button" value="Continue" name="B1"
onClick="location.href='store_result.cfm';""></p>
</center></div>
</form>
var错误=0
对于(e=0;e//html
var结果=0
//你的剧本在这里
//根据需要计算结果的值
$('#res').val(结果);
Html:
<input type="button" value="Continue" name="B1" onclick="location.href='store_result.cfm?'+document.result[0].value;" />
store_result.cfm:
<script>
var yourVar = location.href.split('?')[1];
</script>
var yourVar=location.href.split(“?”)[1];
或者您可以设置cookie。更改
<input type="button" value="Continue" name="B1" onClick="location.href='store_result.cfm';"">
然后可通过下一页的查询字符串获得该值。将该值分配给表单中的隐藏输入。
<input type="button" value="Continue" name="B1" onClick="location.href='store_result.cfm';"">
<input type="button" value="Continue" name="B1" onClick="location.href='store_result.cfm?result=' + escape(document.result[0].value);"">