I have two tables and an input inside a form that more or less goes like this:
the table code (the two tables are the same, except for a slight difference in what table it calls):
<table cellpadding="0" cellspacing="0" class="paperTable searchResultContainer">
<thead>
<tr>
<th>Name</th>
<th>ID</th>
<th>Company Reg.</th>
<th>Postcode</th>
</tr>
</thead>
<tbody>
<?php while ($row = $items->fetch_assoc()) : ?>
<tr class="row" data-address1="<?php echo $row['address1']; ?>"
data-address2="<?php echo $row['address2']; ?>" data-address3="<?php echo $row['address3']; ?>"
data-county="<?php echo $row['address4']; ?>" data-postcode="<?php echo $row['postcode']; ?>"
>
<td><?php echo (strlen($row['name']) > 0 ? $row['name'] : '-'); ?></td>
<td><?php echo (strlen($row['id']) > 0 ? $row['id'] : '-'); ?></td>
<td><?php echo (strlen($row['company_reg_no']) > 0 ? $row['company_reg_no'] : '-'); ?></td>
<td><?php echo (strlen($row['postcode']) > 0 ? $row['postcode'] : '-'); ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
and my input is a simple one-liner checkbox that asks if none of the above matches the search..
what I'm trying to do, if the user clicks a table row, it posts the .data() attributes of the <tr>
tag to the next step in the form, which is another page.
I've tried the hidden input idea, but because it's in a while loop where the inputs share the same name, the value of the input will be the last in the loop because it's last set. I've also tried ajax:
$.ajax({
data: $(this).data(),
type: 'post',
url: 'stepDos.php',
success: function(data)
{
window.location.replace('/path/to/stepDos.php');
}
});
which didn't work when I var_dumped $_POST it returned empty.
I also tried a $.post function:
$.post('/path/to/stepDos.php', {data: data}, function(ev)
{
window.location.replace('/path/to/stepDos.php');
});
again no avail - anything I'm missing?
Thanks