1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

jquery form submission help

Discussion in 'jQuery' started by cancer10, Jul 1, 2008.

  1. #1
    Hi,

    I am trying to run a simple jQuery script that would load a php page "load.php" on click of a submit button and the load.php page would return the value of "tname" variable which is "John" in this case.

    Following is my jQuery script.
    
    	<script src="jquery-1.2.6.js"></script>
    <script>
    $(document).ready(function(){
    
    	$("form#myform").submit(function() {
    
    		$.get("load.php", { tname: "John", ttime: "2pm" });
    		$("#quote").load("load.php");
    	return false;
    	});
    
    });
    
    </script>
    
    <div id="quote"></div>
    <form method="post" id="myform">
    <input name="submit" type="submit" value="Submit" />
    </form>
    
    Code (markup):
    load.php page script
    <?php
    echo $_GET['tname'];
    ?>
    PHP:
    However, the above does not work.


    Can you help me plz?


    Thanx
     
    cancer10, Jul 1, 2008 IP
  2. =Messa=

    =Messa= Peon

    Messages:
    104
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well, it works.
    It does exactly what you scripted it to do.

    If you want to simply "GET load.php" file while passing something to it, just do it with normal JavaScript.

    window.location="load.php?tname=John&ttime=2pm";
    Code (markup):
    <script src="jquery-1.2.6.js"></script>
    <script>
    $(document).ready(function(){
    $("form#myform").submit(function(){
    window.location="load.php?tname=John&ttime=2pm";return false;
    });});
    </script>
    <div id="quote"></div>
    <form method="post" id="myform">
    <input name="submit" type="submit" value="Submit" />
    </form>
    
    Code (markup):
     
    =Messa=, Jul 1, 2008 IP
  3. cancer10

    cancer10 Guest

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Question:

    Can I have 2 Submit buttons in a form one for adding and the other for deleting?

    Well, I wanna do the addition and deletion in jQuery.

    How do I implement the condition statement in jQuery that if submit button is add then do the add function and if the submit button is delete then do the delete function?


    Thanx
     
    cancer10, Jul 3, 2008 IP