Page 1 of 1
Passing dynamic table row data
Posted: Tue Dec 08, 2009 6:40 am
by PhpDog
I have a html page which is dynamically generated from php. The page contains a form and a table whos rows contain a checkbox whith a name of 'rowx' (where x is an incrementing number).
How can I get the individual values of the ticked checkboxes in the page please when the data is passed via a Get?
Re: Passing dynamic table row data
Posted: Tue Dec 08, 2009 6:56 am
by Weiry
If you are ONLY passing the TICKED check boxes through GET and nothing else, you could just loop through the $_GET array on the form submit page.
Or you will have to think about forming them into an array then submitting.
Check out this example of a check box array
Re: Passing dynamic table row data
Posted: Tue Dec 08, 2009 7:06 am
by PhpDog
Many thanks weiry. I really like the array idea.
Much appreciated.

Re: Passing dynamic table row data
Posted: Tue Dec 08, 2009 7:08 am
by hemakumarrr
If u want to get only checked values means u have to pass the values in javascript
<input type="checkbox" name="chk[]" value="1">
<input type="checkbox" name="chk[]" value="2">
<input type="checkbox" name="chk[]" value="3">
<input type="checkbox" name="chk[]" value="4">
for only checked
<script language="javascript">
function chkval()
{
var chk=document.getElementsByName('chk[]');
var str='';
for(i=0;i<=chk.length-1;i++)
{
if(chk.checked==true)
{
str=str+"chkval[]="+chk.value+"&";
}
}
var url="sample.php?"+str;
window.location=url;
}
</script>
sample.php
<?PHP
$chkval=array(1000);
$i=0;
foreach($_REQUEST['chkval'] as $value)
{
$chkval[$i] = $value;
$i++;
}
?>
that values stored in array $chkval.
Re: Passing dynamic table row data
Posted: Wed Dec 09, 2009 5:37 am
by PhpDog
Very nice. Thanks hemakumarrr.