Question

Problème de folie ici.

Quand ma page se charge: <body onload="getClientDateTime();">

Il exécute cette fonction: document.getElementById('ClientDateTime').value="hello world";

Qui devrait théoriquement insérer & "; hello world &"; dans un champ caché: <INPUT TYPE="hidden" name="ClientDateTime" id="ClientDateTime" value="">

Mais elle ne travaille pas.

Si je change le champ pour taper " text " alors cela fonctionne comme il se doit, mais pas comme & "Caché &"; S'il vous plaît, aidez!

Était-ce utile?

La solution

Cela fonctionne réellement car il alerte la valeur correcte:

<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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top