Hello Friends,

I have checkbox which is generated dynamically. Here the code is :

	while($row1 = mysql_fetch_array($result))
		<label><?php echo $i++ ?><input type="checkbox" name="chk_list[]"  value="<?php echo $row1['Veh_id'];?>" class="txt" onClick=""><?php echo $row1['Veh_nm']; ?></input></label></br>
	<?php  } 

Now, I want to insert IDs and related information which checkboxes are checked. So, I tried small javascript on button when its clicked.

function validate()
			var chk = document.frm.chk_list;
			//alert (chk);
			for(i=0; i<chk.length; i++)
			alert (chk[i].value);

now thing is how can I access this value in PHP? Is there any trick to pass array from javascript and use them in PHP code??

Thanking You,
Hakoo Desai.

if you have placed checkbox chk_list[] in the html <form> element, then you can submit the form with action=some.php.

Now in your php file
you will get array of selected values

Here n is number of selected check boxes,
Here Unselected checkboxes are not available in the array.

You can also use loop for getting its value.

	$chk_list = $_POST['chk_list'];
	foreach($chk_list as $key=>$Veh_id)
		echo '<br />'.$Veh_id.' is checked';

Add this code.
This code will print all forms posted data.

    echo '<pre>';

Post your output here.