通过选择两个下拉框值来执行jQuery或JavaScript更改功能

时间:2018-06-24 11:03:46

标签: javascript php jquery laravel

我正在使用laravel做一个项目,我在表单中有一个3-4下拉框。 我的查询就像是从第一个下拉框中选择一个值,然后从第二个下拉框中选择一个值一样。我的条款和条件中有一个句子

我的HTML(因为使用laravel php,所以为blade.template)是

<div class="row">
                    <div class="col-sm-4">
                    <div class="form-group">
                        {{ Form::select('drop_one',[ '1' => 'Abc', '2' => 'Al Badia', '3' => 'Residence' , '4' => 'Fortunato', '5' => 'Solitaire', '6' => 'Living '], null, ['class' => 'form-control','id' => 'drop-one-select']) }}</div>
                </div></div>

我的第二个下拉列表是

<div class="row">
                <div class="col-sm-6">
                        <div class="form-group">
                        {{ Form::select('drop_two', ['0' => 'Minor', '1' => 'Major'], null , ['class' => 'form_control','id' => drop-two-select

我的HTML代码是

<div class="row">
                    <div class="form-group">
                        <label class="col-xs-3 control-label">Terms and Conditions</label> 
                        <div id="agree-terms-other">
                        <div class="col-xs-9">
                            <div class="agree-terms">
                                <ul>
                            <div id="secdepo"></div>
<li>I understand that structural alterations is considered.</li>
                                    <li>I confirm that we will not interfere with or in any way  to modify it</li>
                                    <li>I confirm that the works will be carried out in accordance with best trade practice .</li>

我的JavaScript代码是

$('input[name="drop_one"],input[name="drop_two"]').change(function () { 
    var dropone = $("#drop-one-select").val();
    var droptwo = $("#drop-two-select").val();
    var secdepo ;

    if (dropone == 2 && dropone == 0) {
             secdepo ='<li>A refundable security deposit of AED 500.00 </li>'
      } else {
        secdepo = '<li>A refundable security d`enter code here`eposit of AED 5,000.00 </li>'
       }
        $('#secdepo').empty().append(secdepo);
});

0 个答案:

没有答案