For some reason my check box isnt controlling the fileupload field I have. Can anyone see what is going wrong with this? When I check the box it does nothing and i’m not getting any errors returned?
<script type="text/javascript">
function checkBox() {
var changeimage=document.forms["myform"]["changeimage"].checked
if (changeimage) {
document.forms["myform"]["picupload"].style.display='';
} else {
document.forms["myform"]["picupload"].style.display='none';
}
}
</script>
...
<input type="checkbox" name="chnageimage" id="changeimage" onclick"checkBox();" />
<label for="changeimage"></label>
<br />
<label for="picupload"></label>
Picture
<input type="file" name="picupload" id="picupload" style="display: none;"/>
<br />
<img src="userpics/<?php echo $row['Photo'] ?>" /></p>
Its much better to do this.
Change your HTML checkbox like this. Pass
thisobject of the clickedHTMLElementon theonclickeventNow you can change your javascript like this.
No valid value for
.style.displaytakes the value''. It should beblockin this example.