Hey all,
I feed a bit stupid asking this question, but I have teared my hear out for a day, and still got nowhere.
I have installed Revo and build a nice login page. I also build a profile page so the user can add/change its profile. So far so good....now the gender setting....I would like to have a radio or selectbox to do this. So far I have:
<select name="gender" id="gender">
<option value="1">Male</option>
<option value="2">Female</option>
</select>
No rocket science so for, but now I would like to use the [[+gender]] field to select the right option.
I can use:
<select name="gender" id="gender">
<option value="1" select>Male</option>
<option value="2">Female</option>
</select>
But then everybody is male!
Is there anybody who can help me with the secret formula do it flips to male in stead [[+gender]] == 1 and flips to female if [[+gender]]==2?
Thanks
Onno
After a restless night, I figured out how to solve this. I don’t know if this is the best (or the) way to do this, but it works for me.
I figured out, I needed a snipped to execute the PHP if then statement for me. So In the template chunk on the spot where the radio buttons should appear, I included [[!MaleFemale? &gender=`[[+gender]]`]] So basically I call a new snippet and send the gender value to it.
Then I created the snippet "MaleFemale and included the following:
<?php
if ($gender == 2) {echo "
<label><input name=’gender’ type=’radio’ value=’1’ >Male</label>
<label><input name=’gender’ type=’radio’ value=’2’ checked >Female</label>";}
else {echo"
<label><input name=’gender’ type=’radio’ value=’1’ checked >Male</label>
<label><input name=’gender’ type=’radio’ value=’2’ >Female</label>";}
?>
It works!
Ps I don’t like the exploded approach, so if anybody still have a better suggestion, feel free to share.
Onno