We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13836
    • 7 Posts
    Not exactly. I have two different forms. Both are hidden to start with. The user picks an option from a list of questions via radio buttons, and the correct form is displayed using a JS effect. When the user is submitting that form, I need to:

    a) if error, display the proper form and hide the other form, by testing some POST variables
    b) if successful, show no forms and display eForm thank you page

    I am thinking I can do this by using placeholders which will store the correct html to hide the form and I’ll use my snippet to hold the logic and set the placeholder. Just having trouble with placeholders show in my chunks, which are being called by eForm.
      • 34017
      • 898 Posts
      2 ways to do this.

      1) without a placeholder (if using jquery)
      # if you have a dropdown
      <input type="radio" name="which_form" value="first">
      <input type="radio" name="which_form" value="second">
      

      # in jquery, say if input.which_form == first, then show first form. if input.which_form == second, then show second form. else show neither form
      # that way you wouldnt have to do anything with eform. It would be based on jquery when the page is loaded. If the form doesnt validate, it will return the form with what was previously filled, so the radio will still be checked.

      option 2)
      function detectForm ( &$fields ) {
        // set the placeholders
        global $modx;
        if ($fields[which_form]) == 'first' {
          $output = '<style to hide here>;
        } elseif ($fields[which_form == 'second') {
          $output = '<style to hide here>';
        } else {
          $output = '<style to hide here>';
        }
        $modx->setPlaceholder('contactdisplaystatus',$output);
        return true;
      }
      


      Then in your code, put the placeholder [+contactdisplaystatus+]. I think that should work, tho I think the jquery would be easiest.
        Chuck the Trukk
        ProWebscape.com :: Nashville-WebDesign.com
        - - - - - - - -
        What are TV's? Here's some info below.
        http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
        http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
        • 13836
        • 7 Posts
        Need to use option 2. Won’t be able to test if we are on the form error page VS thank you page using Jquery/JS.

        The problem with option two is that I’m already using that code and those placeholders don’t seem to make it to my chunks through eForm. The function is being executed (as I’ve tested with some output) but placeholders are not being saved for some reason. Any thoughts?