This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 3

How to reset hidden fields?


  1. Javo01
    Member

    Hi, I'm creating a Form with payments, it has four dropdown fields, only one of these is visible and they change his visibility selecting an option of four radio buttons, the problem is when one of the dropdowns are hidden and the user has already selected a value in it, the price that is assigned to that option in the dropdown remains selected and it's added to the total plus the price of the option of the dropdown that is visible now

    So I'm looking for a way to reset the values of the hidden fields.

    Posted 11 years ago #
  2. simonb
    Member

    I am having this same problem. Is there any way to unload the price if the field is hidden by the user?

    Posted 11 years ago #
  3. simonb
    Member

    I ask again as I cannot fix this.

    I am using the Payment with Merchant set to Check/Cash with Variable Amount which I have set for each field.

    If a field is hidden ( to me at least) it should unload the values
    ( Or an option supplied in the admin panel to either say "Unload Prices if hidden" OR "Keep Prices if hidden" )

    Example:-

    Click on checkbox in the form ADD MORE GOODS = No Yes
    User clicks Yes and it displays your hidden fields you want to show if YES is checked ( Using Logic )

    It will then open 3 Check boxes which when each is clicked on, adds an amount to your total.

    If they change their mind and select ADD MORE GOODS = NO - it will hide the field.

    If the field is hidden by the user the prices in those 3 fields should be subtracted from the total amount as they think that hiding the fields will delete the added goods that they have clicked on.

    At the moment the values stay wether hidden or visible.

    So my question is

    How to unload PAYMENT value when field is HIDDEN if they change their mind.

    The Payment system as it is just won't work the way it is set now. ( Using hide/show fields )

    Can someone let me know of a fix or help in anyway.

    Great software and the support is fantastic!
    Gotta thank Yuniar for lightening response to a bug I found in the latest version.
    Fixed within 24 hours. ( And on a Sunday )
    Cheers

    Posted 11 years ago #
  4. simonb
    Member

    Yuniar has advised me that the total hidden price values won't calculate when the user hits submit
    It only calculates all displayed values ( Tested by me and works )
    So best case for now is either don't hide fields through logic etc or don't show running total.
    Email total price is correct if the user hides the fields ( hidden fields are not added in email sent ).

    Posted 11 years ago #
  5. Javo01
    Member

    Actually I've made it by putting a dropdown without a default value and modifying the helper-functions.php a little bit around the line 1969 replacing this:

    if($rule_show_hide == 'show'){
    				$action_code_primary 	= "\$('#li_{$element_id}').show();";
    				$action_code_secondary  = "\$('#li_{$element_id}').hide();";
    			}else if($rule_show_hide == 'hide'){
    				$action_code_primary 	= "\$('#li_{$element_id}').hide();";
    				$action_code_secondary  = "\$('#li_{$element_id}').show();";
    			}

    with this:

    if($rule_show_hide == 'show'){
    				$action_code_primary 	= "\$('#li_{$element_id}').show();";
    				$action_code_secondary  = "\$('#li_{$element_id}').hide();";
    
    				$action_code_secondary  .= "\n\t\t\$('#element_{$element_id}').val('');";
    				$action_code_secondary  .= "\n\t\t\$('#element_{$element_id}').change();";
    
    			}else if($rule_show_hide == 'hide'){
    				$action_code_primary 	= "\$('#li_{$element_id}').hide();";
    				$action_code_secondary  = "\$('#li_{$element_id}').show();";
    
    				$action_code_primary  .= "\n\t\t\$('#element_{$element_id}').val('');";
    				$action_code_primary  .= "\n\t\t\$('#element_{$element_id}').change();";
    
    			}

    that makes that when the payment field it's hided the values are erased and the total it's reset.

    IMPORTANT!

    This only will be useful if the form has only 1 payment field visible because the counter of the total price will completely reset each time the visible field it's hidden

    Posted 11 years ago #

RSS feed for this topic

Reply