tags:

views:

1382

answers:

2

How do I pass the values of txtname and tel as variables to the .load???

$(document).ready(function(){
    $("#add").click(function(){
        $("#result").load("add.php", {name: #txtname});
    });
});

The html:

<p>Name:<input type="text" name="name" value="" id="txtname" /></p>
<p>Telephone:<input type="text" name="tel" id="tel" value="" /></p>
<input type="submit" value="Submit" id="add" />
A: 
$(document).ready(function(){
  $("#add").click(function(){
    $("#result").load("add.php", {
      'name': $("#txtname").val(), 
      'telephone': $("#tel").val()
    });
  });
});
Jonathan Sampson
+1  A: 
$(document).ready(function() {
    $("#add").click(function() {
       $("#result").load("add.php", {
           name: $("#txtname").val(), 
           tel: $("#tel").val()
       });
    });
});
Tim S. Van Haren