javascript - Update dropdown selected value to hyphen(-) as soon as text box clicked -


i have amount dropdown, initial selected value $10, , amount textbox, project requirement user start typing in textbox dropdown value should change "-" , again user clicks on dropdown value in textbox should blank , hyphen should removed, please suggest how achieve this. below code(no script written far):

<div class="selectcontainer ui-grid-a" id="dd2">     <select class="left" name="card1selectamount" data-mini="true" id="giftcardamount1"      style="width: 30%;padding-left: 20px" onclick="dropdownclicked()">         <option value="10" selected="selected">$10</option>         <option value="15">$15</option>         <option value="20">$20</option>         <option value="25">$25</option>         <option value="30">$30</option>         <option value="35">$35</option>         <option value="40">$40</option>         <option value="45">$45</option>                           <option value="50">$50</option>         <option value="75">$75</option>         <option value="100">$100</option>         <option value="150">$150</option>         <option value="200">$200</option>         <option value="250">$250</option>         <option value="300">$300</option>         <option value="350">$350</option>         <option value="400">$400</option>         <option value="450">$450</option>         <option value="500">$500</option>     </select> </div> <div class="ui-grid-b">     <input type="number"  name="card1enteramount" id="giftcardamountinput1"          class="right" placeholder="or - enter amount" style="width: 30%;     padding-right:20px; height: 20%" onmousedown="enteramt()"/> </div> 

take on fiddle if want:

http://jsfiddle.net/yss2z/5/

js

$('#giftcardamountinput1').on('change keyup', function(){     if ($('#giftcardamount1').val() != '-') {         $('#giftcardamount1').append('<option selected="selected" value="-">-</option>');     } });  $('#giftcardamount1').on('change', function(){     $('#giftcardamountinput1').val('');     $('#giftcardamount1').find('option[value="-"]').remove(); }); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -