Forum Moderators: open
2. Your version is slightly different than holyhttp's, which is why it's not working. :-) Compare, if you like to pursue the why's.
3. Minor, note the spaces I've added between attributes compared to yours (should still work though.)
4. Move your events to external attachments onLoad, so your document is not cluttered up with onClicks, onMouseovers, and other white noise. You can then safely move them into an external document for even cleaner HTML.
5. Remember, if JS is disabled this won't work, so duplicate on the server side.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
<!-- Doctype ALL ON ONE LINE -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled</title>
<script type="text/javascript">
window.onload=function() {
if (document.getElementById('chkbox')) {
document.getElementById('chkbox').onclick=function() { populateHidden(this.checked); };
}
};
function populateHidden(isChecked) {
if (document.getElementById('submode')) {
document.getElementById('submode').value=(isChecked==true)?'PERIODIC':'';
// Remove the below after verifying it works
alert("hidden is->" + document.getElementById('submode').value);
}
}
</script>
</head>
<body>
<form action="">
<input type="checkbox" class="style11" id="chkbox" name="chkbox">Yes
<input type="hidden" name="submode" id="submode" value="NEED THIS TO SAY PERIODIC">
</form>
</body>
</html>
So, in reality, it should be a radio selection (or select dropdown):
Recurring:<br>
<input type="radio" name="submode" value=""> No<br>
<input type="radio" name="submode" value="PERIODIC"> Yes<br>