0

在下面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>
4

3 回答 3

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>
于 2012-06-18T10:57:18.817 回答
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>

Or you can set cookie.

于 2012-06-18T11:00:40.673 回答
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);"">

然后它将通过下一页的查询字符串提供。

于 2012-06-18T11:03:40.923 回答