Hello,
I don’t do much Javascript work and I was hoping someone could help me debug the following code.
I am looking to disable a form part (a file upload field) if they do not check off a checkbox.
File Field Name: userfile
Checkbox Name: editimage
Here is the javascript
<script>
function disablefield()
{
// check everything you need to check and then
if (document.forms[0].editimage.value == "yes"){
document.forms[0].userfile.disabled = false;
} else if (document.forms[0].editimage.value == "") {
document.forms[0].userfile.disabled = true;
}}
</script>
Here is parts of the HTML form. The checkbox and the file field-
<input onChange="disablefield(this);" name='editimage' type='checkbox' id='editimage' value='yes'>
<input disabled='disabled' name='textfield' type='text' value='http://www.' size='13'>
The javascript is placed in between the two.
Please help!
Thanks,
peter