-1

I need to create an IF that allow me to define a specific rule. I have a customer portal page where customers can open tickets. The form is developed in order to insert some information like: “software product” and “environment” both are defined as dropdown list. In addition we have other fields like “Suite version”. The IF I need is:

If (software product = ‘TEST’) then HIDE the field “Suite Version”

It is needed because the value “TEST” will open a new level of the “Software Product” field. I can use Jquery JavaScript.

Many thanks.

  • 1
    of course you can do this. What have you tried so far? what is not working as expected? where are you stuck? – tacoshy Apr 14 '21 at 19:39
  • and the JS line you looking for, are looking something like that: `if (software product === "test") { document.querySelector("field").style.display = "none"; } else { document.querySelector("field").style.display = "block"; }` – tacoshy Apr 14 '21 at 19:46
  • Since you are using Jquery, you can use methods like: $(#IdElement).show() or .hide() – Byron Alex Apr 14 '21 at 20:04
  • There are so many examples here showing what you describe, did none of those help? Random eg https://stackoverflow.com/q/11918397/6089612 – Don't Panic Apr 15 '21 at 07:05
  • Does this answer your question? [jQuery: hide and show an input element](https://stackoverflow.com/questions/11918397/jquery-hide-and-show-an-input-element) – Don't Panic Apr 15 '21 at 07:05

3 Answers3

1

is this what you want ?? check below code

    $( document ).ready(function() {
    $('#SoftProd').change(function(){
        $('#pp').html($(this).val());
        if($(this).val() == "Test")
        {
            $('#SuiteVersion').hide();  
        }
        else
        {
            $('#SuiteVersion').show();
        }
        });
});
       
<Select id="SoftProd"> Software Product
   <option selected value="">Select option...</option>
   <option value="Test">Test</option>
   <option value="other">other</option>
</Select>

<input type="text" Placeholder="Suite Version" id="SuiteVersion" name="SuiteVersion">

<!--Jquery-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
Ammad Amir
  • 433
  • 3
  • 7
0

you can try js

css

 #Suite_Version {
     display: none;
  }

JS

 var software_product = $('#software_product').val();
 if (software_product === "test") { 
      $("#Suite_Version").hide();
  } else {
      $("#Suite_Version").show();
 }
0

I tried to use this code but unfortunately doesn’t work. Consider that I am new in this programming language.

jQuery(document).ready(function() var software_product = $('#helpdesk_ticket_custom_field_cf_product_1815896').val(); { if (software_product === "AMHS"){ Jquery("#helpdesk_ticket_custom_field_cf_suite_version_1815896").parent().parent().hide(); } else { Jquery("#helpdesk_ticket_custom_field_cf_suite_version_1815896").parent().parent().show(); } });