[英]pass a javascript variable within a html page into a html form (on the same page) for submission to perl cgi
<script type="text/javascript">
var id = getValue("ID");
document.write(id);
</script>
<form action="cgi-bin/runalg.cgi" method="post" enctype="multipart/form-data">
<input type="radio" name="genome" value="E.Coli"> <i>E.Coli</i> <input type="radio" name="genome" value="Human"> Human<br>
<input type="submit" name="submit" value="Submit"/>
<input type="reset" name="reset" value="Clear"/>
</form>
</body>
How do I get the value of the JavaScript variable (var id) into the form so that on submission I can retrieve it in the runalg.cgi
using the $q<-param("ID")
command? 如何将JavaScript变量(变量ID)的值输入表单,以便在提交时可以使用$q<-param("ID")
命令在runalg.cgi
检索它?
you can write it directly: 您可以直接编写:
<script type="text/javascript">
document.write('<input type="hidden" name="ID" value="'+id+'"/>');
</script>
Add a hidden field. 添加一个隐藏的字段。 Set the value in that field to the value of the variable in Javascript. 将该字段中的值设置为Javascript中变量的值。
<form action="cgi-bin/runalg.cgi" method="post" enctype="multipart/form-data">
[...]
<input type="hidden" name="ID" value="default">
</form>
And then on javascript: 然后在javascript上:
<script type="text/javascript">
document.forms[0].elements["ID"].value = getValue("ID");
</script>
The index for the form may vary in your document. 表单的索引在您的文档中可能会有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.