?
Solved

Submit the task separately

Posted on 2014-04-16
3
Medium Priority
?
357 Views
Last Modified: 2014-04-22
Hi,

I have a form with two button but i want to submit  each task activity  separately as the functionality are different how i can submit them separately in jquery

thanks

<form:form id="main" action="maintask.html" method="GET">

 

<input id = "Maintask1" type="button" value="Maintain task1" >
<input id = "maintask2" type="button" value="Maintain task2"  >



</form:form>

Open in new window



In jquery i have to submit  these two task separately how to do that it on

 $( "#Maintask1").click( function() { 
	   
    
  });

Open in new window


 $( "#Maintask2").click( function() { 
	   
    
  });

Open in new window

0
Comment
Question by:roy_sanu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Assisted Solution

by:jayakrishnabh
jayakrishnabh earned 332 total points
ID: 40006130
$("#Maintask1").click(function () {
                //main.action = "maintask.html";
                $("#main").submit();

            });
            $("#Maintask2").click(function () {
                //main.action = "maintask1.html";
                $("#main").submit();

            });

If you wanna submit to two different htmls for each button click, set the action of the form to required page or html by uncommenting the first statement in each function.
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 336 total points
ID: 40006268
Not really clear on what you need.

If you're submitting the same form to the same URL, but want to distinguish between the 2 buttons, then simply change them to input type="submit", give each a different name, and then check server-side which one was clicked - only the clicked one will exist in the GET array.

If you need to submit the same form to different URLs then your jQuery would look something like this:

$('#Maintask1').click(function() {
	$('#main').attr('action', 'url1.php').submit();
});

$('#Maintask2').click(function() {
	$('#main').attr('action', 'url2.php').submit();
});

Open in new window

If you need an AJAX submit (submit the form in the background without changing pages), then let us know
0
 
LVL 53

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 332 total points
ID: 40010550
Or, place the items you want submitted first in one form,then the rest in another .

$(". Maintask1").click(function() {
        $("form#main").submit();
 });
$(". Maintask2").click(function() {
        $("form#second_form").submit();
 });

Open in new window

If using ajax, you can also "hide" the 2nd form until the first is submitted.
0

Featured Post

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question