单选按钮单击下拉值更改相同值

时间:2015-09-22 14:02:08

标签: javascript jquery html css

我有四个单选按钮在任务我的单选按钮看起来我的单选按钮四个值看起来像

 Conv

 FHA

 VA

 USDA

如果用户在时间下拉值选择Conv时也下降四个值与下拉相同

我的jsfiddle https://jsfiddle.net/cao26pjv/

我如何根据单选按钮选择

选择下拉菜单

2 个答案:

答案 0 :(得分:1)

$("input:radio").click(function() {

  var k = $(this).val();

  $('#ddlCompare1').val(k);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-md-2  padding-Zero">
  <label id="lblFHA" style="float:left">
    <input id="loantype" type="radio" value="jumbo" name="loantype" onClick="javascript:loanTypeChanged()" />&nbsp Conv.</label>
</div>

<div class="col-md-2  padding-Zero">
  <label id="Label4" style="float:left">

    <input id="radio" type="radio" value="fha" name="loantype" checked onClick="javascript:loanTypeChanged()" />&nbsp FHA</label>
</div>


<div class="col-md-2  padding-Zero">
  <label id="va" style="float:left">

    <input id="radio" type="radio" value="va" name="loantype" onClick="javascript:loanTypeChanged()" />&nbsp VA</label>
</div>


<div class="col-md-2  padding-Zero">
  <label id="Label5" style="float:left">

    <input id="radio" type="radio" value="usda" name="loantype" onClick="javascript:loanTypeChanged()" />&nbsp USDA</label>

</div>



<br/>
<br/>
<br/>

<div class="col-md-2  padding-Zero">
  <select id="ddlCompare1" class="dropdown" onChange="javascript:CompareLoantype(true);">
    <option value="jumbo">Conv</option>
    <option selected value="fha">FHA</option>
    <option value="va">VA</option>
    <option value="usda">USDA</option>
  </select>
</div>

答案 1 :(得分:1)

您可以像这样使用更改事件:

public class AcquistoDVDRichiesto implements IsSerializable, CustomEnum {
    private int codice_carrello;
    private String utente;
    private int numero;
    private String film;
    private int fornitura;

    public AcquistoDVDRichiesto(){}
    public AcquistoDVDRichiesto(int c, String user){
        utente=user;
        codice_carrello=c;
    }

    public void generateCodeBasket(){
        if(film!=null && numero!=0 && fornitura!=0){
            codice_carrello=Math.abs(film.hashCode()+((Integer)numero).hashCode()+
                    ((Integer)fornitura).hashCode()+tipo_supporto.DVD.hashCode());
        }
    }
}

DEMO