Javascript 仅基于特定的选择选项加载div控制器
嗨,我有一个改变功能,加载一个控制器与div内容在一个模式内,如图所示 我的问题是,每当我更改任何选择选项时,它都会加载,如果只选择了每月选项,我希望加载控制器 我的HTML选择选项如下:Javascript 仅基于特定的选择选项加载div控制器,javascript,html,codeigniter,Javascript,Html,Codeigniter,嗨,我有一个改变功能,加载一个控制器与div内容在一个模式内,如图所示 我的问题是,每当我更改任何选择选项时,它都会加载,如果只选择了每月选项,我希望加载控制器 我的HTML选择选项如下: <div class="form-group"> <label for="registrationmodeofpayment" class="col-sm-4 control-label">Mode of Payment: </label> <div c
<div class="form-group">
<label for="registrationmodeofpayment" class="col-sm-4 control-label">Mode of Payment: </label>
<div class="col-sm-8">
<select class="form-control" name="registrationmodeofpayment" id="registrationmodeofpayment">
<option value="">Select Mode of Payment</option>
<option value="Annual">Annual (Full)</option>
<option value="Monthly">Monthly</option>
</select>
</div>
</div>
// The div that have the id of modeofpayment.
<div class="col-md-12" id="modeofpayment"></div>
$("#registrationmodeofpayment").unbind('change').bind('change', function() {
// Loads the controller
$("#modeofpayment").load('registration/assessModeofPayment');
});
public function assessModeofPayment()
{
$div3 = '</table>
<table class="table table-bordered">
<tr>
<th>Monthly Tuition Fee:</th>
<td width="210px">*Amount*</td>
</tr>
</table>
';
echo $div3;
}
控制器:
<div class="form-group">
<label for="registrationmodeofpayment" class="col-sm-4 control-label">Mode of Payment: </label>
<div class="col-sm-8">
<select class="form-control" name="registrationmodeofpayment" id="registrationmodeofpayment">
<option value="">Select Mode of Payment</option>
<option value="Annual">Annual (Full)</option>
<option value="Monthly">Monthly</option>
</select>
</div>
</div>
// The div that have the id of modeofpayment.
<div class="col-md-12" id="modeofpayment"></div>
$("#registrationmodeofpayment").unbind('change').bind('change', function() {
// Loads the controller
$("#modeofpayment").load('registration/assessModeofPayment');
});
public function assessModeofPayment()
{
$div3 = '</table>
<table class="table table-bordered">
<tr>
<th>Monthly Tuition Fee:</th>
<td width="210px">*Amount*</td>
</tr>
</table>
';
echo $div3;
}
支付的公共功能()
{
$div3
每月学费:
*数量*
';
echo$div3;
}
好吧,我们已经得到了答案:
$("#registrationmodeofpayment").unbind('change').bind('change', function() {
if($(this).val() == 'Monthly') {
// Loads the controller
$("#modeofpayment").load('registration/assessModeofPayment');
}
});
希望我能帮点忙。非常感谢您!