• Resolved Asjad Aamir

    (@asjad492)


    Hi, I want to know how to hide or show one field that is dependent on other two fields? The other two fields have dropdowns. So, I want that if I select sepcific options from these two other fields, it would hide or show that third field

Viewing 15 replies - 16 through 30 (of 52 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @asjad492

    If you use the val method with textual values, you should pass two parameters:

    <script>jQuery(document).on('change', '[id*="fieldname40_"],[id*="fieldname16_"]', function(){ 
    	IGNOREFIELD('fieldname14');
    	IGNOREFIELD('fieldname42');
    	IGNOREFIELD('fieldname43');
    	IGNOREFIELD('fieldname44'); 
    	if(AND(getField('fieldname40').val(true, true) == 'Basis-Shop', getField('fieldname16').val(true, true) == 'Normales Angebot (Jetzt kaufen)')) { 
    		ACTIVATEFIELD('fieldname14'); 
    	} else if(AND(getField('fieldname40').val(true, true) == 'Top-Shop', getField('fieldname16').val(true, true) == 'Normales Angebot (Jetzt kaufen)')) {
    		ACTIVATEFIELD('fieldname42');
    	} else if(AND(getField('fieldname40').val(true, true) == 'Top-Shop', getField('fieldname16').val(true, true) == 'Auktionsangebot')) {
    		ACTIVATEFIELD('fieldname42');
    	} else if(AND(getField('fieldname40').val(true, true) == 'Basis-Shop', getField('fieldname16').val(true, true) == 'Auktionsangebot')) {
    		ACTIVATEFIELD('fieldname42');
    	}
    });</script>

    Best regards.

    Thread Starter Asjad Aamir

    (@asjad492)

    Just for my knowledge, what does true, true indicate?

    Thread Starter Asjad Aamir

    (@asjad492)

    And one more thing, where should I insert this HTML field? at the very start of the form or in the middle?

    Plugin Author codepeople

    (@codepeople)

    Hello @asjad492

    The first true ask for the field value in raw mode, without preprocessing, the second one tells the plugin that parse it as JSON.

    You can insert the “HTML Content” field at the beginning of the form structure.

    Best regards.

    Thread Starter Asjad Aamir

    (@asjad492)

    Okay. It works. But the problem is when I preview the form and values are pre selected, it doesn’t process the code. But when I click on drop down and start selecting values, it then processes that HTML code.

    Plugin Author codepeople

    (@codepeople)

    Hello @asjad492

    In this case, you can force an onchange event in any of the involved fields. Add the following piece of code to the HTML Content field.

    <script>
    fbuilderjQuery(document).one('showHideDepEvent', function(){jQuery('[id*="fieldname40_"]').change();});
    </script>

    Best regards.

    Thread Starter Asjad Aamir

    (@asjad492)

    Script tags are separate for this? If possible can you merge it with previous code?

    Plugin Author codepeople

    (@codepeople)

    Yes, of course, you can merge both.

    Best regards.

    Thread Starter Asjad Aamir

    (@asjad492)

    I mean to say can you paste merged code again?

    Plugin Author codepeople

    (@codepeople)

    Hello @asjad492

    Sorry, but if you need us to implement your project you must contact us directly through the plugin website.

    Best regards.

    Thread Starter Asjad Aamir

    (@asjad492)

    I just want to know how to combine this below code with your additional script?

    <script>jQuery(document).on('change', '[id*="fieldname40_"],[id*="fieldname16_"]', function(){ 
    	IGNOREFIELD('fieldname14');
    	IGNOREFIELD('fieldname42');
    	IGNOREFIELD('fieldname43');
    	IGNOREFIELD('fieldname44'); 
    	if(AND(getField('fieldname40').val(true, true) == 'Basis-Shop', getField('fieldname16').val(true, true) == 'Normales Angebot (Jetzt kaufen)')) { 
    		ACTIVATEFIELD('fieldname14'); 
    	} else if(AND(getField('fieldname40').val(true, true) == 'Top-Shop', getField('fieldname16').val(true, true) == 'Normales Angebot (Jetzt kaufen)')) {
    		ACTIVATEFIELD('fieldname42');
    	} else if(AND(getField('fieldname40').val(true, true) == 'Top-Shop', getField('fieldname16').val(true, true) == 'Auktionsangebot')) {
    		ACTIVATEFIELD('fieldname44');
    	} else if(AND(getField('fieldname40').val(true, true) == 'Basis-Shop', getField('fieldname16').val(true, true) == 'Auktionsangebot')) {
    		ACTIVATEFIELD('fieldname43');
    	}
    });</script>
    Thread Starter Asjad Aamir

    (@asjad492)

    I did it. leave it. Can you please tell how to use for loop with if condition if one field has too many dropdowns?

    Thread Starter Asjad Aamir

    (@asjad492)

    Is this correct?

    (function(){
      var options = ['Ger?te > Computer, Tablets & Netzwerk', 'Option 2', 'Option 3', ...];
    
      // Loop through the options array
      for (var i = 0; i < options.length; i++) {
        // Set the value of fieldname45 to the current option in the loop
        fieldname45 = options[i];
    
        // Your code block goes here
        if (AND(fieldname16 == 'Normales Angebot (Jetzt kaufen)', fieldname45 == options[i], fieldname17 == 'Keine', fieldname26 == 'Eurozone und Schweden')) {
            if (AND(fieldname39 == 'Ja', fieldname40 == 'Basis-Shop')){
                if (fieldname31 < 300) {
    
            return SUM(fieldname30*0.1,fieldname31*0.065,0,0);
                } else {
                      return SUM(fieldname30*0.1,fieldname31*0.02,0,0);
    
                } 
            } else if (AND(fieldname39 == 'Ja', fieldname40 == 'Top-Shop')){
                if (fieldname31 < 300) {
    
            return SUM(fieldname30*0.05,fieldname31*0.065,0,0);
                } else {
                      return SUM(fieldname30*0.05,fieldname31*0.02,0,0);
    
                } 
            } else if (AND(fieldname39 == 'Ja', fieldname40 == 'Premium-Shop')){
                if (fieldname31 < 300) {
    
            return SUM(fieldname30*0.05,fieldname31*0.065,0,0);
                } else {
                      return SUM(fieldname30*0.05,fieldname31*0.02,0,0);
    
                } 
            } else if (AND(fieldname39 == 'Ja', fieldname40 == 'Platin-Shop')){
                if (fieldname31 < 300) {
    
            return SUM(fieldname30*0.05,fieldname31*0.065,0,0);
                } else {
                      return SUM(fieldname30*0.05,fieldname31*0.02,0,0);
    
                } 
            }
            else if (fieldname39 == 'Nein') { 
                if (fieldname31<990) {
               return SUM(0.35,fieldname31*0.065,0,0);
          } else {
          return SUM(0.35,fieldname31*0.02,0,0);
          }
            }
        } 
      }
    })();
    
    Thread Starter Asjad Aamir

    (@asjad492)

    I am using it but not working.

    Plugin Author codepeople

    (@codepeople)

    Hello @asjad492

    You are copying and pasting code examples from other sources. The code examples cannot be used literally, they exists to teach you a concept. For example, this piece of code is not valid in javascript:

    var options = ['Ger?te > Computer, Tablets & Netzwerk', 'Option 2', 'Option 3', ...];

    Furthermore, our plugin minifies the equations code. For this reason, you cannot use one line comment structures in the equations, like:

    // Your code block goes here

    If you want to include comments in the equations, use block comments format:

    /* Your code block goes here */

    I”m sorry, but this is a forum about our plugin, and your questions are not precisely about our plugin. We cannot implement your project through the plugin forum.

    Best regards.

Viewing 15 replies - 16 through 30 (of 52 total)
  • The topic ‘Hide and Show fields’ is closed to new replies.