1

This is my first code with jQuery, so be indulgent please. The code below is part of a table in which each row displays: a reload button (Reload.gif), and two comboboxes (cmb1 and cmb2). Here is the edited code for just one row:

<table>
<form name="myformname" form action="Handler.php" method="post">
   <tr>
      <td>
          <input type="hidden" name="MyQuestion" value="0">
          <input type="image" src="Reload.gif" border="0"/>
      </td>
      <td>
          <select name="cmb1"><option>One</option><option>Two</option></select>
      </td>
      <td>
          <select name="cmb2"><option>A1</option><option>A2</option></select>
      </td>
   </tr>
</form>
</table>

Variables MyQuestion, cmb1 and cmb2 (user-selected) are passed to Handler.php (as all are in the same form), that search data in databases and reload the page with the new data. This is working OK.

But now I want to change the logic, cause I dont want to reload the whole page, but only the row that was clicked. I tried with jQuery something like this (OnClick added to Reload.gif!):

<table>
   <tr>
      <td>
          <input type="hidden" name="MyQuestion" value="0">
          <input type="image" onclick="recp('0')" src="Reload.gif" border="0" name="MyQuestion" value="0"/>
      </td>
      <td>
          <select name="cmb1"><option>One</option><option>Two</option></select>
      </td>
      <td>
          <select name="cmb2"><option>A1</option><option>A2</option></select>
      </td>
   </tr>
</table>

And in the header I added this code (I took it from here)

function recp(id) {
  $('#myStyle').load('data.php?id=' + id);
}

I got some results for the id, but here is my question: In the

load('data.php?id=' + id)

, can I send multiple variables (id, cmb1 and cmb2)?

Community
  • 1
  • 1
CMArg
  • 1,525
  • 3
  • 13
  • 28

2 Answers2

4

To send multiple variables you could use for example,

load('data.php?id=' + id + '&var1=' + var1 + '&var2=' + var2)

For more examples and other ways to do it, have a look in the jQuery manual for the load() function.

Erlesand
  • 1,525
  • 12
  • 16
0

Why not use .serialize()?

$("#myStyle").load('data.php?' + $("form[name=myformname]").serialize());
glambert
  • 96
  • 2
  • 16