开发者

Problem with Javascript not inputting value into hidden fields

开发者 https://www.devze.com 2022-12-09 13:18 出处:网络
Maddening problem here. When my page loads: <body onload=\"getClientDateTime();\"> It runs this function: docum开发者_高级运维ent.getElementById(\'ClientDateTime\').value=\"hello world\";

Maddening problem here.

When my page loads: <body onload="getClientDateTime();">

It runs this function: docum开发者_高级运维ent.getElementById('ClientDateTime').value="hello world";

Which theoretically should insert "hello world" into a hidden field: <INPUT TYPE="hidden" name="ClientDateTime" id="ClientDateTime" value="">

But she no worky.

If I change the field to type "text" then it works like it should but not as a "hidden". Please help!


This actually works as it alerts the correct value:

<html>
<head>
    <title>Test</title>
</head>
<body onload="document.getElementById('ClientDateTime').value='hello world'; alert(document.getElementById('ClientDateTime').value);">

<input type="hidden" name="ClientDateTime" id="ClientDateTime" value="" />

</body>
</html>
0

精彩评论

暂无评论...
验证码 换一张
取 消