Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Submit the task separately

Posted on 2014-04-16
3
Medium Priority
?
365 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 44

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 54

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
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 …

636 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