I have a series of radio buttons, which onClick will either reveal or hide a Div:
Reveal the Div:
<input type="radio" name="con[4]" value="1" onclick="toggleLayer4(this.checked);" id="con4" />
Hide the Div:
<input type="radio" name="con[4]" value="0" onclick="toggleLayer4(!this.checked);" checked="checked" id="con4" />
JavaScript:
function toggleLayer4(val)
{
if(val == '1' || val === true)
{
document.getElementById('con4').checked = true;
document.getElementById('con4PSTN').style.display = 'block';
}
else if(val == '0' || val === false)
{
document.getElementById('con4').checked = false;
document.getElementById('con4PSTN').style.display = 'none';
}
}
Now the problem, when the pag is recalled, I can get the radio button checked like this:
<input type="radio" name="con[4]" value="1" onclick="toggleLayer4(this.checked);" <? if ($conn_count[3] == 1){echo "checked=\"checked\"";}?> id="con4" />
But I need a away of calling the JavaScript function to reveal the div if the radio button is checked, I have tried to echo toggleLayer4(this.checked);
within the PHP if statement inside tags, however this just seems to reurn the text in the html??
There must be a way, not really versed in JS.
Cheers, B.