4
Quote:
Maybe I can be so impertinent and ask you for a solution to auto-collect all form data with jquery.
That's actually quite easy with a very handy jquery function called serialize:
<script language="javascript">
$(document).ready(function() { //Finish loading the entire page before processing any javascript
$("#subBut").click(function(event) {
var formContent = $("#form1").serialize(); //get all form fields and properly format them for use with $_GET
$("#box").load('myserv.php',formContent);
});
});
script>
<form name="form1" id="form1" method="post" action="">
<label>Name
<input type="text" name="textfield" id="textfield">
label>
<input type="button" name="subBut" id="subBut" value="Submit">
form>
<br />
<div id="box">Ajax calldiv>
Now if your form is being generated dynamically, we need to change the click function to $.live:
<script language="javascript">
$(document).ready(function() { //Finish loading the entire page before processing any javascript
$("#subBut").live("click", function() {
var formContent = $("#form1").serialize(); //get all form fields and properly format them for use with $_GET
$("#box").load('myserv.php',formContent);
});
});
script>
<form name="form1" id="form1" method="post" action="">
<label>Name
<input type="text" name="textfield" id="textfield">
label>
<input type="button" name="subBut" id="subBut" value="Submit">
form>
<br />
<div id="box">Ajax calldiv>
let me know if this helps