dcsimg
Results 1 to 5 of 5

Thread: [RESOLVED] Click Button Event Always Firing

  1. #1

    Thread Starter
    Lively Member FunkySloth's Avatar
    Join Date
    Aug 2016
    Posts
    79

    Resolved [RESOLVED] Click Button Event Always Firing

    I'm just wondering why this alert method in Click Event always firing when I'm selecting my select element.

    Code:
            $('#Register').click(function () {
    
                if ($('#account_type').val() == "def") {
                    alert('Please select an account type.');
                    return;
                }
            });

    Code:
    <select id="account_type" class="form-control login-type" onchange="AccountType()">
    </select>

  2. #2
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,141

    Re: Click Button Event Always Firing

    What is the code for the AccountType function?

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,556

    Re: Click Button Event Always Firing

    Thread moved to JQuery forum, since the language appears to be JQuery.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Lively Member FunkySloth's Avatar
    Join Date
    Aug 2016
    Posts
    79

    Re: Click Button Event Always Firing

    This is the code for AccountType Function:

    Code:
            function AccountType()
            {
                switch ($('#account_type').val()) {
                    case "def":
                        HideContent();
    
                        break;
                    case "app":
                        ShowContent();
    
                        $('#FNAME').css('display', 'block');
                        $('#MNAME').css('display', 'block');
                        $('#LNAME').css('display', 'block');
                        $('#EMAIL_ADDRESS').css('display', 'block');
                        $('#PASSWORD').css('display', 'block');
    
                        break;
                    case "emp":
                        ShowContent();
    
                        $('#FNAME').css('display', 'block');
                        $('#MNAME').css('display', 'block');
                        $('#LNAME').css('display', 'block');
                        $('#EMAIL_ADDRESS').css('display', 'block');
                        $('#PASSWORD').css('display', 'block');
    
                        break;
    
                    default:
                        HideContent();
                        break;
                }
            }

  5. #5

    Thread Starter
    Lively Member FunkySloth's Avatar
    Join Date
    Aug 2016
    Posts
    79

    Re: Click Button Event Always Firing

    Found the line of code that made the unusual behavior of the button click. There are two elements with the same Register id.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width