简体   繁体   中英

Onclick On Radio Button Not Working

So I have this radio button and text field in a form. When the page loads, the disable field method gets called and disables the text field. What I am trying to do next is to re enable the text field by activating the radio button. Hence I have an onclick event on the radio button that calls the enablefield method. But its refusing to reactivate the textfield. Is it the syntax you reckon?

<form>
<input type="radio" name="asiinternship" value="Tadween Publishing" onclick="enableField(applyingforother)" />Other <input type="text" name="applyingforother" maxlength="56" style="width:143px;margin-bottom:20px;" />
</form>

<script>
        function enableField(myField)
            {
            myField.disabled = false
            return true
            }   

        function disableField(myField)
            {
            myField.disabled = true
            return true
            }       

        disableField(document.forms["contact_form"].applyingforother)

</script>

You're missing quotes:

 onclick="enableField(applyingforother)

should be:

 onclick="enableField('applyingforother')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM