views:

27

answers:

3

I have a working dynamic image and text list page that shows results in table form. I've added check boxes (name = "select") to each item in the list results with the (relevant) code below. I want to filter the corresponding art_id's from just the ones with select ="1"

echo "<tr align=\"left\" padding=\"1\"> 
                <td align=\"left\" width=\"0%\" height=\"120\" >
    <a href=\"$path$image_link\">
              <img src=\"$path$image_link\" height=\"85\" width=\"85\"></a><br />
    </td>
    <td align=\"left\" width=\"0%\">
//CHECKBOXES ADDED HERE  <input name=\"select\" type=\"checkbox\" value=\"1\" >
    <input name=\"art_id\" type=\"hidden\" value=\"$art_id\" />
    </td>

Then I want to sent via $_POST to another page for another query/echo. I guessed at something like this for grabbing the vars on the 2nd page:

$t_art_id =  $_POST["art_id"], ["select ='1'"];

Would appreciate any good ideas on the right approach.

Thanks Allen

A: 

Why dont you use only the checkbox?

while the value of an checkbox only is submitted if the box is checked, you dont need on serverside the value of the checkbox to determine, if the box is checked(the occurance in the POST-Array will be enough). So you can use the value-attribute to submit the art_id

<input name=\"select[]\" type=\"checkbox\" value=\"$art_id\" />

The way you currently have it there is no chance to get a relation between checkbox and hidden-input.

Dr.Molle
+1  A: 

You can do in simple way ;

like this :

     <input name="checkbox"   type="checkbox" class="checkbox" onClick="Compressartid('<?php echo $art_id; ?>',this)" ?>> 

in Compressartid function store ticked id in a hidden field and use id's in hidden field as selected id's.

I hope it will be helpful :). cheers.

seed_of_tree
A: 

Thanks for responding.

I first tried (in the echo on the first page):

with: $art_id0 = $_POST['art_id'];

echo $art_id0; on the second page

I'm still getting only the first item in the dynamic image list to go over to the second page, html_transPage.php.

Also, confused about the onClick="Compressartid('') suggestion. Should the hidden field be named 'Compressartid' and can an echo work inside an echo?

thanks Allen

artworthy