Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
115
rated 0 times [  119] [ 4]  / answers: 1 / hits: 20634  / 14 Years ago, fri, july 23, 2010, 12:00:00

I have two submit buttons and one form. How do I check what submit button was selected in my jquery code?



<% using (Html.BeginForm(UserInfo, Home, FormMethod.Post, new { id  = formNext })) { %> 
....
<input id=submitHome type=submit name=goHome value=Home />
<input id=submitNext type=submit name=getNext value=Next />
<% } %>


$(document).ready(function() {
$('#formNext').submit(function() {
//Code Does not work but looking at something like this...
//$('#submitHome').click(function() {
// navigate to Home;
//});
//$('#submitNext').click(function() {
// return true;
//});
});
});

More From » jquery

 Answers
0
$('#submitHome').click(function() {
//navigate to Home;
});
$('#submitNext').click(function() {
return true;
});


These should work if you pull them outside of the form.submit(). (right now those handlers are being attached after the form is submitted, which is too late since the click has already occurred)


[#96128] Wednesday, July 21, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sophiak

Total Points: 242
Total Questions: 90
Total Answers: 103

Location: Liechtenstein
Member since Wed, Dec 8, 2021
3 Years ago
sophiak questions
;