Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6989063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:09:48+00:00 2026-05-27T19:09:48+00:00

I have 2 buttons on my page. Button 1 is executing a javascript function

  • 0

I have 2 buttons on my page. Button 1 is executing a javascript function and another one is used for form processing. The problem is that button 1 is overriding the value and function of button 2.

Button 1 (not in a form) has the following html code:

<input id="show_hint" class="button" type="submit" value="Hint" onClick="location.href='#hint'" />

The javascript attached to it is:

// Button 1
$(function(){
  var count = 3,
      $btn = $('input[type="submit"]'); 
      $btn.val($btn.val()+' ('+count+')')

  $btn.click(function(){
      $btn.val($btn.val().replace(count,count-1));
      count--;
      $('#hintscore')
        .hide()
        .css({
            bottom: 30,
            left: 300,
            opacity: 1,
        })
        .show()
        .stop()
        .delay(200)  
        .animate({'bottom':75, opacity: 0},1000);

      if(count==0) {
            return !$btn.attr('disabled','disabled');
      }
  })
});

Button 2 (in a form) has this html code:

<input id="showmenu_win2" class="button" type="submit" value="Menu" />

The javascript attached to it is:

$('#form').submit(function() {
        $.ajax({   
            type: "POST",
            data: $("#form").serialize(), 
            cache: false,  
            url: "insert.php"  
        });   
        return false;
    });

So these two are conflicting with each other and it has something to do with the type=”submit”. But how can I fix this?

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:09:48+00:00Added an answer on May 27, 2026 at 7:09 pm

    This part of your JS:

    $btn = $('input[type="submit"]'); 
    

    is selecting both buttons and thus will attach the same behavior to both buttons.

    Since you have an id on each button, you can select exactly the button you want by id:

    $btn = $("#show_hint");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have buttons on a page that look like: <p> <a href=view.php> <input type=button
I have 4 buttons on a page. Each button opens a modal window and
I have a page with some dynamically added buttons. If you click a button
I have a button on an ASP.Net page that will call Response.Redirect back to
I have a page with a button that when I click, it retrieves data
I have button on my page for Export To Excel. The ButtonClick function is
I have a page that consists of two frames: one being a flash app,
I have a form that I'm validating with JavaScript before allowing the form to
Multiple sites have buttons where you can tweet, digg, etc. On this page you'll
I have the following markup: <p class=managebox> <button value=Add page> <img src=page_add.png alt=Add more

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.