[英]How do you include a javascript variable in a hyperlink?
I have pretty simple code 我有很简单的代码
<input type="hidden" name=passtophp value=variable>
The variable is created in javascript in the head of the document. 该变量是在文档开头的javascript中创建的。 Unfortunately when I put in the variable name it is captured as a string and passed through instead of the variable's actual value.
不幸的是,当我输入变量名时,它被捕获为字符串并通过而不是变量的实际值。 How can I pass through the variable's value?
如何传递变量的值? Thank you!!
谢谢!!
var myVariable = 'myValue';
document.getElementById('passtophp').value = myVariable ;
Ensure you specifty an ID on the hidden field though. 但是,请确保您在隐藏字段上指定一个ID。
<input type="hidden" name='passtophp' id='passtophp' />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.