-1

I have a image that when you click on it you go to www.google.com (for example). Above such image I have placed an imput that submit a form. When I click in the button it makes the 2 actions:

  1. Submit the form
  2. Goes to www.google.com

Does somebody know the cause?

My intention is that when you click the button the only action is done is the first one (Submit the form) and stay in the same page and when you click in the image it goes to www.google.com

Does somebody know how can I get that when I click on the button the only thing that happen is to submit the form?

  • 4
    We would have to see the actual code to find the issue. – Rayshawn Dec 05 '12 at 00:17
  • 1
    Did you check line 103? I had a problem on line 103 today... – Incognito Dec 05 '12 at 00:18
  • This should answer your question, very similar question: [http://stackoverflow.com/questions/5733808/submit-form-and-stay-on-same-page][1] [1]: http://stackoverflow.com/questions/5733808/submit-form-and-stay-on-same-page – zeMinimalist Dec 05 '12 at 00:23

2 Answers2

1

Just can do this if you are using JQuery:

$('#id-clickable-image').click(function(event){
    //This line will prevent the normal behavior of the click
    event.preventDefault
    //Code to submit the form... you just fill it
    var field1 = $('#input-id-1').val()
    .
    .
    .
});

You can check the JQuery documentation: http://api.jquery.com/event.preventDefault/

  • Finally the solution was to use the stopPropagation() jQuery function in the input button, thus the click event propagation stops and it does not get to the input event. – Albertito Albertongo Dec 05 '12 at 16:40
0

why dont you set a hidden variable for post back and check if the variable is set to some value after form submission. if it was set then redirect to google after whatever you do with that code.

user704988
  • 436
  • 9
  • 24