我想获取下拉菜单的选定值。我必须将href中的值作为第4个细分受众群传递。我没有使用表格,也没有提交。在我看来,我有:
<?php for($i=0;$i<count($estimates);$i++) { ?>
<tr>
<td>
<span><?php echo $estimates[$i]->id_job; ?></span>
</td>
<td>
<span><?php echo $estimates[$i]->date_of_plans; ?></span>
</td>
<td>
<span><?php echo $estimates[$i]->business_name; ?></span>
</td>
<td>
<span><?php echo $estimates[$i]->job_title; ?></span>
</td>
<td>
<span><?php echo $estimates[$i]->date_estimated_needed; ?></span>
</td>
<td>
<span>JC</span>
</td>
<td>
<select id="status" name="status">
<option value="IN PROGRESS">IN PROGRESS</option>
<option value="NOT STARTED">NOT STARTED</option>
<option value="AWAITING CLIENT">AWAITING CLIENT</option>
<option value="COMPLETE - QC">COMPLETE - QC</option>
<option value="COMPLETE">COMPLETE</option>
</select>
</td>
<td style='border:0px none;'>
<a id="test" href="<?php echo site_url('frontpage/adminestimates')."/".$estimates[$i]->id_job ?>" class='btn btn-success' style='padding-left:24px; padding-right:24px; padding-top:1px; padding-bottom:1px;border-radius:4px;'>EDIT</a>
</td>
</tr>
<div id="result"></div>
<script>
$("#test").live("click", function(){
$("#result").load($(this).attr("href")); //result is the div where I have to load the new page. (as im using tabs so have to show page in div.
return false;
});
</script>
Controller.php
uri-> segment(3)echo是要编辑的作业的作业ID。如何获取uri-> segment(4):(因为我必须将此值传递给模型,然后将其保存到数据库以向客户端显示作业状态。
public function adminestimates()
{
echo $this->uri->segment(3);
//echo $this->uri->segment(4);
}
试试这个代码:
$("#result").load($(this).attr("href")+"/"+$("#status").val());
现在,您将在网址中获得第4个细分。
您正在for循环中创建具有相同ID和名称的状态下拉列表。因此,存在ID和名称重复的可能性。因此,将您的下拉列表ID和名称更改为唯一。
在视图文件中,如下更改选择:
<select id="status_<?php echo $estimates[$i]->id_job;?>" name="status_<?php echo $estimates[$i]->id_job;?>">
<option value="IN PROGRESS">IN PROGRESS</option>
<option value="NOT STARTED">NOT STARTED</option>
<option value="AWAITING CLIENT">AWAITING CLIENT</option>
<option value="COMPLETE - QC">COMPLETE - QC</option>
<option value="COMPLETE">COMPLETE</option>
</select>
然后是a
标签
<td style='border:0px none;'>
<a id="<?php echo $estimates[$i]->id_job;?>" href="<?php echo site_url('frontpage/adminestimates')."/".$estimates[$i]->id_job ?>" class='btn btn-success' style='padding-left:24px; padding-right:24px; padding-top:1px; padding-bottom:1px;border-radius:4px;'>EDIT</a>
</td>
在js代码中:
<script>
$("a.btn-success").live("click", function(){
var id = $(this).attr("id");
$("#result").load($(this).attr("href")+"/"+$("#status_"+id).val()); //result is the div where I have to load the new page. (as im using tabs so have to show page in div.
return false;
});
</script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句