tags:

views:

54

answers:

4

Hi i have this code where you can select the date you like to attend the meeting. How can I have this possible to select 2 dates at the same time? Because in this code, one can only select 1 date. What should I add in here?

       <div style="background-color:#aaa">
       <form method="post" action="[~[*id*]~]">
       <input type="hidden" name="formid" value="registrationForm" />

       <p>
       <table>

       <tr>
       <td><label for="workshop" style="margin:0.5em">Termine:</label>
       <td>
       <input type="checkbox" name="termine1" value="Montag 4. Oktober 2010" eform="Termine::1"/>&#09;Montag 4. Oktober 2010 <br/>
        <input type="checkbox" name="termine2" value="Mittwoch 13. Oktober 2010" />&#09;Mittwoch 13. Oktober 2010 <br/>
        <input type="checkbox" name="termine3" value="Freitag 22. Oktober 2010" />&#09;Freitag 22. Oktober 2010 <br/>           
    </td>
</tr>   

<tr>
    <td><label for="email" style="margin:0.5em">Email:</label></td>
    <td><input type="text" name="email" size="60" maxlength="60" eform="Email:email:1" /><td>
</tr>
  <tr>
    <td><label style="margin:0.5em; display:block" for="kopieren" >Bitte kopieren Sie den Anti-Spam Code ein: </label>
    <img src="[+verimageurl+]" alt="verification code" border="1" style="margin:0.5em"/></td>
    <td valign="top"><input type="text" name="vericode" size="20" />
</tr>


   <tr>
    <td rowspan="3" valign="right">
        <input align="right" type="submit" name="submit" style="margin:0.5em" value="Register" />
    </td>
</tr>

</table>

=========

This would be the other form look like, do I need to add here for the other dates?

  <h3>Registration</h3>



 <table>
<tr valign="top"><td>Termine</td><td>[+termine1+]</td></tr>
<tr valign="top"><td>Termine</td><td>[+termine2+]</td></tr>  
<tr valign="top"><td>Termine</td><td>[+termine3+]</td></tr>          
<tr valign="top"><td>Email</td><td>[+email+]</td></tr>    
 </table>
+1  A: 

Make them Checkboxes instead?

<input type="checkbox" name="workshop1" value="morning-with-visit" eform="Selected Dates::1"/>&#09;18 August 2010<br/>
<input type="checkbox" name="workshop2" value="morning-without-visit" />&#09;19 August 2010<br/>
<input type="checkbox" name="workshop3" value="afternoon-with-visit" />&#09;20 August 2010 (12h50)<br/>  

Try it out here.

Stephen
@Stephen: thanks I changed it but after that, it only shows the last date selected. how can it display the two dates that you selected?Thanks
tintincute
@tintincute Can you please explain "it only shows" - what showsonly the last date? The website? The server (PHP) code?
Stephen
@Stephen:if you try to execute my code, and then select the dates that you like,you can select it already it's ok.But after clicking on the "Register" button you will get the summary of information that you selected.From there you can see only one dates will be displayed. You can try it here:http://www.wikima4.com/index.php?id=361
tintincute
Actually, when clicking "Register", I get a page with no "Termine" listed (which I assume means "Dates"). Can you edit your question above, or provide here in a comment, the PHP you use on the server to extract what checkboxes the user has ticked?
Stephen
@Stephen:thanks,yes the "termine" that means the dates that you selected. Did you select 2 dates? Please see above edited question
tintincute
@Stephen: i know the reason why you didn't get any display dates, because I put 1,2,3 in the "name:termine" like what you did above. But I delete the numbering and leave "name:termine" then it will display the dates, but only the last one you selected.
tintincute
@tintincute In order to tell the difference between the three checkboxes, you will have to give them different names and then go through each one (often in a loop if you give them sequential names like I did) in order to find which ones are ticked. You are using server side PHP to process this, right?
Stephen
@Stephen: hmm, im not really sure?what do you mean with server side PHP? i'm editing this in the cms
tintincute
Well, how are you taking the input from the form, and then putting it into the result the user gets?
Stephen
Update: By the look of your website now, you seem to be getting there - I see multiple dates!
Stephen
@Stephen:please check my edited code. That's what I did now. It will display the 2 dates if you select 2 dates, but then there's a word "termin" for the 3rd date and it's blank. Maybe I should do if and else here? But not really sure where to put that.
tintincute
@Stephen: that's an EForm. I created 4 different chunks each of them. Wait, I also saw that there is a php code under snippets. but not sure if that is something
tintincute
A: 

Change the inputs to type="checkbox". You will likely need to change the name attribute to correctly process server-side, assuming that's what you're doing.

roryf
A: 

You can't have multiple selections in a radio group. You need to use something like chekboxes and perform the validation yourself, to make sure that 2 values are selected. This can be done using javascript to get client-side validation before posting the values to the server.

Rouan van Dalen
Validation should honestly always be server-side. You can still do the client-side for user feedback and/or aid, but the true *validation* really ought to be server-side, otherwise it can be sidestepped.
pinkgothic
A: 

I agree with the three answers supplied that you should use checkboxes, thus:

    <input type="checkbox" name="morning-with-visit" eform="Selected Dates::1"/>&#09;18 August 2010<br/>
    <input type="radio" name="morning-without-visit" />&#09;19 August 2010<br/>
    <input type="radio" name="afternoon-with-visit" />&#09;20 August 2010 (12h50)<br/>

On the server-side, you will only receive back the boxes that were ticked. Here is a PHP example...

if (isset($_POST['morning-with-visit'])) {
    echo 'They selected "morning-with-visit"';
}

You can make radio inputs multi-selectable, but by putting each in its own name... like this example (I only mention it to say that is IS possible).

    <input type="radio" name="workshop1" value="morning-with-visit" eform="Selected Dates::1"/>&#09;18 August 2010<br/>
    <input type="radio" name="workshop2" value="morning-without-visit" />&#09;19 August 2010<br/>
    <input type="radio" name="workshop3" value="afternoon-with-visit" />&#09;20 August 2010 (12h50)<br/> 

Note that if you do this, you can't actually "un-select" anything, which is bad. So many people use yes-no groups (although checkboxes are more natural for this).

Sohnee
Umm, your first codeblock has one checkbox and two radio-boxes.
Stephen
@Sohnee:Thanks for the input. I changed it to "checkboxes" and i think it's good but the problem is, after it send the confirmation it only displays the last date that you selected. Do i need to change something?
tintincute
@tintincute - you want to check the name of each of them - `$_POST['morning-with-visit'], $_POST['morning-without-visit'], $_POST['afternoon-with-visit']`.
Stephen
@Stephen: i would like to display the selected dates. Where should I add this one? Do I have to add this in the code I gave above?
tintincute
@tintincute Again, I'm afraid you're not being specific enough. What do you mean "i would like to display the selected dates" - where and how do you wish to display them?
Stephen
@Stephen: i edited my answer please see above, and then I gave you the links where you can test it. Please have a look at it and check then you will see that the info's you get will only display 1 date and not the 2 dates or 3 dates that you selected
tintincute