Solved

Submit the task separately

Posted on 2014-04-16
3
346 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
3 Comments
 
LVL 5

Assisted Solution

by:jayakrishnabh
jayakrishnabh earned 83 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 84 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 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 83 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

777 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