html input的value属性怎么设置为变量 你好,能不能详细写出来?非常感谢!

你好,我是新手,菜鸟,

<form action="bankPay.php" method="post" id="submitForm" target="_blank">
<input type="text" name="requestId" id="requestId" value=""/>
<input type="submit" value="提交" onclick="return check()" />
</form>
整个代码是这样,现在需要 id="requestId" 设置成随机字母或数字都可以,25位,每次刷新网页则自动生成,一个字符串变量,我看了你的回答,但不是很明白,你能不能详细写出来?非常感谢!

<script>
    function uuid() {
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 25; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = "-";

var uuid = s.join("");
document.getElementsByName("requestId")[0].id=uuid;
}
</script>
<body onload="uuid()">就可以了

温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网