0

我想做的是每个下拉列表都有提交示例。每个列表都有formopen。这是我的示例代码

<?php $delete = form_open('maintenance/delete',array('name'=>'deleteCheckForm'));
        $active = form_open('maintenance/active',array('name'=>'deleteCheckForm'));
        $disable = form_open('maintenance/disable',array('name'=>'deleteCheckForm'));
?>

<table>
    <tr>
<?php foreach($sample as $list) { ?>
    <td><input type="checkbox" name="type"></td>
    <td>name :<?php echo $list->name; ?></td>
<?php } ?>
    </tr>
</table>



<select onchange="this.form.submit()">
        <option value="<?php echo $delete; ?>">delete</option>
        <option value="<?php echo $active; ?>">active</option>
        <option value="<?php echo $disable; ?>">disable</option>
    </select>

<?php echo form_close(); ?>
4

2 回答 2

0
<html>
<body>
<?php echo form_open('', array('name'=>'deleteCheckForm'))?>
<table>
<?php foreach($sample as $list) { ?>
    <tr>
        <td><input type="checkbox" name="type"></td>
        <td>name :<?php echo $list->name; ?></td>
    </tr>
<?php } ?>
</table>
<select onchange="this.form.action='<?php echo site_url('maintenance')?>/'+this.value;this.form.submit()">
    <option value="delete">delete</option>
    <option value="active">active</option>
    <option value="disable">disable</option>
</select>
<?php echo form_close(); ?>
</body>
</html>
于 2013-08-13T07:05:42.347 回答
0

你可以试试这个

首先在php标签之外制作你的表单

<form action="your_action" id="delete_frm" method="post"></form>
<form action="your_action" id="active_frm" method="post"></form>
<form action="your_action" id="diable_frm" method="post"></form>

那么您的选择选项将像

<select id="select_form_post">
    <option value="delete">delete</option>
    <option value="active">active</option>
    <option value="disable">disable</option>
</select>

那么你的脚本会像

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/ 1.7.1/ jquery.min.js"></script>
<script type="text/javascript">
$("#select_form_post").change(function(){
    var form_to_post=$(this).val();
    if(form_to_post=="delete")
    {
        $("#delete_frm").submit();
    }
    if(form_to_post=="active")
    {
        $("#active_frm").submit();
    }
    if(form_to_post=="disable")
    {
        $("#disable_frm").submit();
    }
});
</script>

如果您需要更多信息,请告诉我。

于 2013-08-13T06:58:25.037 回答