#1
  1. No Profile Picture
    buildmyweb.org
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    NY
    Posts
    62
    Rep Power
    7

    JS Event problem in FF


    i am trying to make a block element show/hide based upon one of two radio buttons in a group being checked. think of the two radio buttons as a toggle switch. works in IE9 and Chrome but not FF.

    here is my HTML radio group:

    PHP Code:
        <tr>
        <td class="form_label">Account Type:</td>            
        <td>
                                                                                        General Contractor: <input type="radio" name="acct_type" value="gc" id="input_gc" <?php if( $_SESSION['reg_acct_type'] == "gc" ){ echo"checked='checked'"; } ?> />
                                                                                        Subcontractor: <input type="radio" name="acct_type" value="sc" id="input_sc" <?php if( $_SESSION['reg_acct_type'] == "sc" ){ echo"checked='checked'"; } ?> />
                                                                                    </td>
                            </tr>
    and here is the javascript:

    Code:
    function show_hide( curr_page )
        {
            // REGISTER page
            if( curr_page == "register" )
            {
                alert("register");
                var input_gc     = document.getElementById("input_gc");
                var input_sc     = document.getElementById("input_sc");
                
                input_gc.onclick    = hide_select;
                input_sc.onclick    = show_select;       
                
                function hide_select()
                {
                    alert("h");
                    var sc_dropdown = document.getElementById("sc_dropdown");
                    sc_dropdown.style.display     = 'none';
                }
                
                function show_select()
                {
                    alert("s");
                    var sc_dropdown = document.getElementById("sc_dropdown");
                    sc_dropdown.style.display     = 'block';
                }
            } // close if( curr_page == "register" )
        } // close function show_hide( curr_page )
    i can get 'alert("register");' to trigger so i know the if statement is true

    'alert("h");' and 'alert("s");' does not trigger when i click either radio button.
    Freelance Web Developer | Web Hosting |
    PHP Applications
    Web Development, Hosting, Graphic Design, SEO
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,041
    Rep Power
    119
    Try this:
    Code:
    inputGC.onclick = function(){hide_select()};
    inputSC.onclick = function(){show_select()};

IMN logo majestic logo threadwatch logo seochat tools logo