Get value from checkbox and echo it

hi all

How can i get value from checkbox and echo that value

i have this below checkbox code for all my products in the row

echo  "<input name='availability[]' type='checkbox' onclick='this.form.submit();' 

value='savl=Store&pidd=310' id='availability[]' />Store"; 

Onclick the form gets submit but i dont get its value;

	echo $savl; /* no value is echo */
	echo $pidd; /* no value is echo */

am i doing something wrong


I would use $_GET instead of $_REQUEST (to be sure you’re using the correct values).

To know why your code isn’t working, do a print_r of $_REQUEST and see what it contains.

Hi guido

after doing print_r also i dont get any values for $savl and $pidd

    [dealer_id] => 9
    [category_id] => 1
    [sub_catg] => 6
    [availability] => Array
            [0] => savl=Store&pidd=340

    [PHPSESSID] => 2622124c72fa9bd4507a38e0a558dac0

Is there any other method of passing values to checkbox and then use them


The values are been past as you can see in your print_r statement, the reason why they are not part of the $_GET superglobal is because they are a value of the checkbox and not of the form action. You can use something simple like the below example to access the values.

if (isset($_GET['availability']) && sizeof($_GET['availability'])) {
    foreach ($_GET['availability'] as $availability) {
        $split = explode('&', $availability);

        foreach ($split as $v) {
            $temp = explode('=', $v);

            echo 'Key: ' . $temp[0] . '<br>';
            echo 'Value: ' . $temp[1] . '<br><br>';

thanks chris

your solution works great