我想做的是每个下拉列表都有提交示例。 每个清单都有开窗。 这是我的示例代码
<?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(); ?>
答案 0 :(得分: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>
如果您还有其他需要,请告诉我。
答案 1 :(得分: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>