#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    21
    Rep Power
    0

    Enable and submit form when radio button is checked


    I made the submit button is disable until one of the radio button is clicked. When it's clicked, it also submit the form but my code didn't do of what I need. Can you tell me what I have wrong here?

    Thanks

    <script>
    function affCheck() {
    document.affform.submit.disabled
    =!(document.affform.contractor.checked || document.affform.emp.checked);
    }
    </script>

    <cfform name="affform" action="" method="post" id="affform">

    <table>
    <tr>
    <td>
    A
    <input type='radio' name='itemtype' id="a" value="a" <cfif form.itemtype eq 'a'> checked="checked"</cfif> onclick="javascript:affCheck(); document.affform.submit()">

    </td>
    </tr>
    <tr>
    <td>
    B
    <input type='radio' name='itemtype' id="b" value="b" <cfif form.itemtype eq 'a'> checked="checked"</cfif> onclick="javascript:affCheck(); document.affform.submit()">

    </td>

    </tr>
    </table>

    <cfinput type="submit" name="submit" id="submit" value="Submit" disabled="disabled">
    </cfform>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    The name and id attributes of your radio buttons are "a" and "b" but you don't reference those attribute values anywhere in your event handler?

IMN logo majestic logo threadwatch logo seochat tools logo