Reputation:
<tr>
<td><form:checkbox path="ftpScanEvents" id="chk" onclick="showMe('div1',this);"/>
<input type="hidden" value="1" name="_ftpScanEvents"/>
FTP Scan Events</td>
</tr>
<tr><td colspan="4">
<table id="div1" style="display:none">
<tr><td>Host Name</td><td>Directory</td><td>User Name</td><td>Password</td></tr>
<tr><td><form:input path="hostName" size="30" maxlength="200"/></td>
<td><form:input path="directory" size="30" maxlength="200"/></td>
<td><form:input path="userName" size="20" maxlength="20"/></td>
<td><form:input path="password" size="20" maxlength="20"/></td>
</tr>
</table>
</td></tr>
javascript:
function showMe (it, chkbox) {
var rr = (chkbox.checked) ? "block" : "none";
document.getElementById(it).style.display = rr;
}
I can hide/show it on checkbox selection. But, what I need is on page load, if checkbox is checked show it else hide...
Upvotes: 0
Views: 231
Reputation: 5389
You need an onload event. Add this to the bottom part of your HTML.
<script type="text/javascript">
window.onload = function() {
showMe('div1',document.getElementById('chk'));
}
</script>
Upvotes: 4