在以下form
中,我需要document.result[0].value
传递onclick
的值作为下一页的表单变量?
具体而言,此document.result[0].value=totalquestions-incorrect.length+ value
需要作为store_result.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>
答案 0 :(得分:0)
// html
<input id='res' type='hidden' value=''>
<script>
var result = 0
// your script here
// calculate the value of result as you wish
$('#res').val(result);
</script>
答案 1 :(得分:0)
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>
或者你可以设置cookie。
答案 2 :(得分:0)
更改
<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);"">
然后它将通过下一页的查询字符串提供。