Solved

Submit the task separately

Posted on 2014-04-16
3
347 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

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

860 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