We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30086
    • 110 Posts
    hi
    i’m having problems with my checkbox in modx it seems it is not working and would like to ask for your help.

    i made a form and the user should select 2 dates or 1 date. this is the sample:
    The problem is, if I select the first date and the second date - it works
    The first date and the third date - it works
    However, if I just select the 2nd date - it doesn’t work
    The 3rd date - doesn’t work as well
    And the 2nd and the 3rd date - doesn’t work as well.
    Can you please tell me where did i go wrong from here?
    Thanks
    Btw, the forms are composed of 4 different ones


    <div style="background-color:#CCDFED">
    <form method="post" action="[~[*id*]~]">
        <input type="hidden" name="formid" value="registrationForm" />
    
       
        <table>
            
        <tr>
            <td><label for="dates" style="margin:0.5em">Dates:</label>
            <td>
                <input type="checkbox" name="date[]" value="Mo 04 Oct"    eform="Date::1"/>	Mo 04 Oct <br/>
                <input type="checkbox" name="date[]" value="Wed 13 Oct " />	Wed 13 Oct <br/>
                <input type="checkbox" name="date[]" value="Fr 22 Oct  "  />	Fr 22 Oct <br/>           
            </td>
        </tr> 
     </table>
        
    </form>
    </div>
    




    And this is the code of mail: Is this correct?

    <h3>The Form</h3>
    
    <p>This is a confirmation [+email+], from the website: </p>
    
    <table>
        <tr valign="top"><td>Date</td><td>[+date[]+]</td></tr>
        <tr valign="top"><td>Date</td><td>[+date[]+]</td></tr>
        <tr valign="top"><td>Date</td><td>[+date[]+]</td></tr>         
    </table>
    

      • 26016
      • 561 Posts
      Hi Tintin,
      I take it you’re using Eform. Very powerful, but not always easy. smiley As far as I can tell, you’ve done a super job setting up the form code.

      But in my experience, strangely enough, I would suggest only one instance of "date" in your email template as per below. I don’t think your way will work (with the subscripts). I think if the user chooses more than one, they may all appear in the one spot in the following template:

      <table>
      <tr valign="top"><td>Date</td><td>[+date+]</td></tr>
      </table>

      This is not clearly documented anywhere, to my knowledge.

      Good luck!
      Dave

      PS: if you’re having other problems, I would suggest trying another variable name besides "date".... I wonder if it’s a reserved word somewhere!
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        You definitely won’t get anywhere with [+date[]+] in the output. The name of the form field gets away with it (it’s actually a kludge workaround to get the browser to handle multiple items of the same name) but as a placeholder it won’t work.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 30086
          • 110 Posts
          yes I’m using Eform.
          So that means I will write it this way?



          <div style="background-color:#CCDFED">
          <form method="post" action="[~[*id*]~]">
              <input type="hidden" name="formid" value="registrationForm" />   
              <table>
                  
              <tr>
                  <td><label for="dates" style="margin:0.5em">Dates:</label>
                  <td>
                      <input type="checkbox" name="date[]" value="Mo 04 Oct"    eform="Date::1"/>	Mo 04 Oct <br/>
                      <input type="checkbox" name="date[]" value="Wed 13 Oct " />	Wed 13 Oct <br/>
                      <input type="checkbox" name="date[]" value="Fr 22 Oct  "  />	Fr 22 Oct <br/>           
                  </td>
              </tr> 
           </table>
              
          </form>
          </div>





          <h3>The Confirmation, what the webmaster will received after the user register the infos</h3>
          
          <p>This is a confirmation [+email+], from the website: </p>
          
          <table>
              <tr valign="top"><td>Date</td><td>[+date[]+]</td></tr>         
          </table>



            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Try to pay attention to your terminology, it can lead to a lot of confusion. The first is a form, but the second is not a form at all, so what you may do in form fields won’t apply. In the form, if you have elements with the same name you use the [] to force it into emulating an array.

            In the email tpl, it’s not a form. You just want the placeholder, which is [+date+].
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 30086
              • 110 Posts
              ok sorry about that, i’m still confused with everything

              Ok, so that means the code is correct now?

              The problem is: if I do that, and if the user will select 2 dates, the last one will only be displayed.
              And I don’t understand why?

              Is it possible that the user can select 2 dates at the same time and the dates selected will also be displayed?
              I can’t find how to have it work
                • 26016
                • 561 Posts
                Yes, Tintin,
                Try it this way, and see what you get. As you noted, the only change is in the email template (which they call a report - somewhat confusing). Even though there’s only one "date" there, if you choose more than one in your form, I’m not absolutely sure without testing, but I think you will see both items in that location. Not perfect, but pretty good.

                Eform is quite powerful, yet likes to be a little mysterious as well. smiley

                Good luck!

                Cheers, Dave

                Quote from: tintincute at Aug 19, 2010, 02:01 AM

                yes I’m using Eform.
                So that means I will write it this way?



                <div style="background-color:#CCDFED">
                <form method="post" action="[~[*id*]~]">
                    <input type="hidden" name="formid" value="registrationForm" />   
                    <table>
                        
                    <tr>
                        <td><label for="dates" style="margin:0.5em">Dates:</label>
                        <td>
                            <input type="checkbox" name="date[]" value="Mo 04 Oct"    eform="Date::1"/>	Mo 04 Oct <br/>
                            <input type="checkbox" name="date[]" value="Wed 13 Oct " />	Wed 13 Oct <br/>
                            <input type="checkbox" name="date[]" value="Fr 22 Oct  "  />	Fr 22 Oct <br/>           
                        </td>
                    </tr> 
                 </table>
                    
                </form>
                </div>





                <h3>The Confirmation, what the webmaster will received after the user register the infos</h3>
                
                <p>This is a confirmation [+email+], from the website: </p>
                
                <table>
                    <tr valign="top"><td>Date</td><td>[+date[]+]</td></tr>         
                </table>




                  MODx and Wordpress development
                  Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4