Hi, everyone
Im new to this forum.
I try to create an input field that have value which is select options. on other test site i tested on it working but when i try on cs cart it does not work. will there be somethings i missed for this.
The values for option 'BB' and 'CC' always switch to the value of option 'AA'. thanks
<div class="inline-block"> <select id="filter" name="filter"> <option value="A">AA</option> <option value="B">BB</option> <option value="C">CC</option> </select> <input id="ifield" value="666" type="text" /> </div>
<script type="text/javascript"> $(document).ready(function() { $('select[name=filter]').change(function() { var input_field = $('input#ifield'); switch ($(this).val()) { case 'A': input_field.val('666'); break; case 'B': input_field.val('888'); break; case 'C': input_field.val('999'); break; } }); $('input#ifield').on('input', function() { var A = '666'; var B = '888'; var C = '999'; var select_field = $('select[name=filter]').val(); var regA = new RegExp(666 + '.*'); var regB = new RegExp(888 + '.*'); var regC = new RegExp(999 + '.*'); if (select_field == 'A') { if (!(regA.test($(this).val()))) { $(this).val(A); } } else if(select_field == 'B') { if (!(regB.test($(this).val()))) { $(this).val(B); } } else if(select_field == 'C') { if (!(regC.test($(this).val()))) { $(this).val(C); } } }) }); </script>