Solved

Submit the task separately

Posted on 2014-04-16
3
335 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
Comment Utility
$("#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 42

Accepted Solution

by:
Chris Stanyon earned 84 total points
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now