Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Value Of Input Field Js Rate Topic   - - - - -

 
  • serey
  • Newbie
  • Trial users
  • Join Date: 23-May 20
  • 2 posts

Posted 23 May 2020 - 02:31 PM #1

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>


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21589 posts

Posted 25 May 2020 - 08:16 AM #2

Do you see any errors in the developer console of your browser? How did you add this code?


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • serey
  • Newbie
  • Trial users
  • Join Date: 23-May 20
  • 2 posts

Posted 28 May 2020 - 09:10 AM #3

Sorry, it my mistake that i tested on an add-on page where I want to add this to.
it working for smarty html.
it should be the add-on that does not support this function.
will there be some code to add to the add-on , if you could help out , thank you.