在页面加载时,我希望 jquery 将 UUID 方法作为值加载到 UUID 字段,以便我看到它在提交时作为参数传递。这个和这个SO 帖子有所帮助,但我仍然没有到达那里......
<FORM ACTION="urlAuction.html" METHOD=GET>
<INPUT TYPE=TEXT NAME="url">
<INPUT id="uuid" TYPE=TEXT NAME="uuid" VALUE="" >
<INPUT TYPE=SUBMIT VALUE=Submit>
</FORM>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
var $uuid = $('#uuid');
$uuid.val(GUID());
});
function GUID ()
{
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
</script>