0

I can't seem to figure out how to run a form for each individual row but at the same time have a form that handles every items in the table. Ex.:

deleteSelected form would control the bulk actions, changeStatus form would control individual items

<form id="deleteSelected">
    <table>
        <tr>
            <td><input type="checkbox" name="deleteSelected[]"/></td>
            <td>Id</td>
            <td>Name</td>
            <td>Phone</td>
            <td>
                <form id="changeStatus">
                    <select name="item_id">
                        <option value="option1">option1</option>
                        <option value="option2">option2</option>
                        <option value="option3">option3</option>
                    </select>
                </form>
            </td>
        </tr>
    <table>
</form>

I know this is wrong since you cannot nest forms for obvious reasons, but this is what i'm trying to accomplish.

A possible solution I have encountered is to create a invisible form filled by javascript with all the checked items id's then do a PHP explode to the POST. But its seems more like a hack than a fix. Any other way??

Thank you.

1 Answer 1

0

form under inner form is not valid so you can use JavaScript function to load page

<script type="text/javascript">
function changestatus(value)
{
    window.location.href="actionurl.php?sendvalue="+value;
}
</script>

call this function onchange event of select box like this

<form id="deleteSelected">
    <table>
        <tr>
            <td><input type="checkbox" name="deleteSelected[]"/></td>
            <td>Id</td>
            <td>Name</td>
            <td>Phone</td>
            <td>
               <!-- <form id="changeStatus">-->
                    <select name="item_id" onchange="changestatus(this.value);">
                        <option value="option1">option1</option>
                        <option value="option2">option2</option>
                        <option value="option3">option3</option>
                    </select>
              <!--  </form>-->
            </td>
        </tr>
    <table>
</form>

<script type="text/javascript">
function changestatus(value)
{
    window.location.href="actionurl.php?sendvalue="+value;
}
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.