当我按下CodeIgniter中表单上的提交按钮时,
如果我在XController/loadX
我的行动是YController/loadY
,
网址变为Xcontroller/loadX/Ycontriller/loadY
,
我希望它只是YController/loadY
。
<form name="SpecAccept"method="post"action="SpecialistController/loadDoctor">
<div class="form-group col-sm-12" id="myDiv" align="right">
<span><label>الولاية</label></span>
<select style="font-size:12px" class="form-control" id="state_name" onchange="change(this)">
<option>--- اختر الولاية ---</option>
<?php
foreach($states as $Object){
echo '<option value="'.$Object->StateID.'">'.$Object->StateName.'</option>';
}
?>
</select>
</div>
<div class="form-group col-sm-6" id="myDiv" align="right">
<span><label>المهنة</label></span>
<select style="font-size:12px" class="form-control" id="career_name" >
<option>--- اختر المهنة ---</option>
<?php
foreach($careers as $Object){
echo '<option value="'.$Object->CareerID.'">'.$Object->CareerName.'</option>';
}
?>
</select>
</div>
<div class="form-group col-sm-6" id="myDiv" align="right">
<span><label>المستشفى</label></span>
<select style="font-size:12px" class="form-control" id="hospitals" name="Hospitals" >
<option value="0" isSelected>اختر الولاية اولاً</option>
</select>
</div>
<div class="form-group col-sm-12">
<button type="sumbit">عرض</button>
</div>
</form>
问题是什么以及如何解决?
答案 0 :(得分:1)
尝试使用javascript
<button type="button" onclick="Function_name();" >عرض</button>
然后在javascript中你可以做到
<script>
function Function_name(){
alert ('I AM HERE');
document.SpecAccept.submit();
}
</script>
警告是查看该按钮是否有效并输入该功能。
如果不起作用,请尝试更改此类型的表单
<?php
$attributes = array(
'id' => 'SpecAccept',
'name' => 'SpecAccept',
'autocomplete' => 'off',
'enctype' => 'multipart/form-data',
);
echo form_open_multipart('SpecialistController/loadDoctor'); // this is the open <form>
?>
然后关闭它会替换<{p>的</form>
标记
<?php echo form_close();?>
答案 1 :(得分:0)
首先,您需要在config.php文件中定义基本URL,如此
$config['base_url'] = 'http://localhost/projectfoldername/';
现在使用表单操作网址
<form name="SpecAccept"method="post"action="<?php echo base_url('SpecialistController/loadDoctor'); ?> ">