-1

I have select option value drop down looks like

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

all four option value have single interest rate

<input name="Compare_interest_rate" id="Compare_interest_rate" class="txt"   type="text" size="6" maxlength="6" style="width:75%" />%</p>

four option value have four default value

FHA value- <?php echo $interest_FHA_default; ?>

VA value-<?php echo $interest_VA_default;?>

USDA value- <?php echo $interest_USDA_default;?>

CONV value- <?php echo $interest_CONV_default;?>

how to show four value depends on drop down select ? if user select FHA value need FHA value .. please any one give me idea ?

Shehary
  • 9,926
  • 10
  • 42
  • 71
samyNathan P
  • 77
  • 12
  • From what i can understand, you want to show the selected drop down value in your input tag. For that you can get the dropdown object **document.getElementById('dd1Compare1');** in your onChange function and then get the selected value. – priya vyas Sep 23 '15 at 15:13
  • yes if i select FHA i want show value textbox – samyNathan P Sep 23 '15 at 15:15
  • possible duplicate of [Get selected text from drop-down list (select box) using jQuery](http://stackoverflow.com/questions/1643227/get-selected-text-from-drop-down-list-select-box-using-jquery) – Martijn Sep 23 '15 at 15:37

1 Answers1

1

In your onChange function do this:

function CompareLoantype() {
    var dd = document.getElementById('ddlCompare1');
    var selectedText = dd.options[dd.selectedIndex].text; // or .value if you want to show value
    document.getElementById('Compare_interest_rate').value = selectedText;
}
priya vyas
  • 195
  • 1
  • 1
  • 10