Debt Consolidation - Computer Programming Tutorials - Rome hotels - Debt Consolidation - Find jobs

PDA

View Full Version : jquery form submission help


cancer10
Jul 1st 2008, 2:48 am
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>


load.php page script
<?php
echo $_GET['tname'];
?>

However, the above does not work.


Can you help me plz?


Thanx

=Messa=
Jul 1st 2008, 9:25 pm
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";

<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>

cancer10
Jul 3rd 2008, 12:51 am
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