0

I have a form whee i am trying to populate the field #ef with the information from the field #emergency2

It works but what i want to happen is for it to pass the text YES or NO in to the second field #ef rather than the weighted value of 0 or 1. I want to keep the numeric value as i am using it for a sum later. However i want the text within the drop down to appear in the second input rather than the numerical value. Any ideas?



  <label>Do you have  £1000 in your emergency fund? </label> 
              <select class="select-css" id="emergency2" name="emergency2” required>
             <option selected="selected">Please Select</option>
              <option value="0">Yes</option>
              <option value="1">No</option>
            </select>




         <p><strong>Your emergency funds is large enough to cover at least 3 months of outgoings:</strong></p>
        
             <input id="ef">
        
         

     <script>
            $('#emergency2').change(function() {
    $('#ef').val($(this).val());
});
            </script>


  • Does this answer your question? [Get selected text from a drop-down list (select box) using jQuery](https://stackoverflow.com/questions/1643227/get-selected-text-from-a-drop-down-list-select-box-using-jquery) – freedomn-m Oct 23 '20 at 09:02
  • I figured it out and found the solution here https://stackoverflow.com/questions/14976495/get-selected-option-text-with-javascript – user2961593 Oct 23 '20 at 09:06

1 Answers1

0

Try this one

$('#ef').val($(this).text());