Madhusudan
Madhusudan

Reputation: 407

how i can pass checkbox value using href in php?

I want to do multiple delete using href link, how can i done ?

This code generate given below error.

Notice: Undefined index: action in
C:\xampp\htdocs\montu\montu\multiple.php on line 32

Warning: implode() [function.implode]: Invalid arguments passed in
C:\xampp\htdocs\montu\montu\multiple.php on line 32



<body>
    <form method="post" action="<?php $_PHP_SELF ?>">
        <table>
            <tr>
                <td>
                    <input type="checkbox" name="action[]" value="1">1
                </td>
                <td>
                    <input type="checkbox" name="action[]" value="2">2
                </td>
            </tr>
            <tr>
                <td>
                    <a href="?id">Click Me..</a>
                </td>
            </tr>

        </table>
    </form>

<?php 
    if(isset($_REQUEST['id']))
    {
        $action=implode(',',$_REQUEST['action']);//convert array value to string values
        echo $action;
    }
?>

Upvotes: 0

Views: 1732

Answers (1)

Hiren Raiyani
Hiren Raiyani

Reputation: 744

Please try like this..

<?php 
    if(isset($_POST['action']))
    {
        //print_r($_REQUEST);
        $action=implode(',',$_REQUEST['action']);//convert array value to string values
        echo $action;
    }
?>
<body>
    <form name="frm" id="frm" method="post">
        <table>
            <tr>
                <td>
                    <input type="checkbox" name="action[]" value="1">1
                </td>
                <td>
                    <input type="checkbox" name="action[]" value="2">2
                </td>
            </tr>
            <tr>
                <td>
                    <a onclick="document.forms['frm'].submit()" href="#">Click Me..</a>
                </td>
            </tr>

        </table>
    </form>

Upvotes: 2

Related Questions