jeudi 2 juin 2016

Troubleshooting a method to show/hide a div when a checkbox is checked

so I have the following HTML code for a checkbox and a hidden div containing a textarea that I need to appear when the checkbox is selected.

HTML

<input type="checkbox" name="q3resp4" value="1" onchange="valueChanged()"/> Other entity (specify):<br>
    <div style="display: none;" id="q3othertxt">
        <textarea rows="4" cols="50" id="q7resp"></textarea>
    </div>

JAVASCRIPT

<script type="text/javascript">
function valueChanged()
{
    if($('.q3resp4').is(":checked"))   
        $(".q3othertxt").show();
    else
        $(".q3othertxt").hide();
}
</script>

I'm not fluent with either language, so I may be making some rookie mistakes here, but every script/code snippet I tried has failed to give me results. So after doing ~90 minutes of research, I'm resorting to a straightforward question.

Thanks for any help guys.




Aucun commentaire:

Enregistrer un commentaire