这应该是非常简单的事情,但我无法得到它。
我想通过表单提交onclick将特定的字段值传递给控制器函数。
<form action="<?php echo base_url();>data/pass" method="post">
<select name="name1" id="name1" onclick="" class="m-wrap" >
<option selected="selected" disabled="disabled">Select</option>
<option value="1">by year</option>
</select>
<form>
答案 0 :(得分:1)
像这样更改您的代码
<form action="<?php echo base_url();?>data/pass" method="post">
<select name="name1" id="name1" onchange="this.form.submit()" class="m-wrap" >
<option selected="selected" disabled="disabled">Select</option>
<option value="1">by year</option>
</select>
<form>
答案 1 :(得分:0)
<form id="form-id" method="post">
<select name="name1" id="name1" class="m-wrap" >
<option selected="selected" disabled="disabled">Select</option>
<option value="1">by year</option>
</select>
<button type="submit" >Onclick</button>
<form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
$(document).ready(function(){
$('#form-id').ajaxForm({
type : 'POST',
dataType: 'json',
url: "<?php echo base_url();>data/pass ",
success: function(res)
{
//Your code success
}
});
</script>``
您可以使用此表单