Author Topic: radio button blues  (Read 11980 times)

0 Members and 1 Guest are viewing this topic.

Offline bigwillhere

  • Newbie
  • *
  • Posts: 22
    • View Profile
radio button blues
« on: February 25, 2008, 09:42:31 PM »
Hi everyone.

I love 4images. I just started to do some custom work. I read everything and I mean everything I could on the forum about radio buttons. I read the explanation in db_field_definitions.php at least 10 times. I must not understand or don't have the expertise to understand what I read because I can't get it to work. I prefer radio button over a pull down menu for gender selection (I say this because someone already had a mod for pull down, but radio is better, so please don't give me a link to that mod since it is pull down).

I hope by showing you the steps I took someone can tell me what I did wrong.

1. In register_form I added:

   <tr>
            <td class="row1"><b>Gender</b></td>
            <td class="row1">
              <input type="radio" name="user_gender" value="Male"{user_gender} />
              Male&nbsp;&nbsp;&nbsp;
              <input type="radio" name="user_gender" value="Female"{user_gender} />
              Female</td>
          </tr>


   2. In db_field_definitions.php I added:

   $additional_user_fields['user_gender'] = array($lang['user_gender'], "radio", 1);


   3. In mysql database I added new fields in 4images_users called user_gender


   4. In member_profile I added the following

   <tr>
             <td class="row2"><strong>Gender</strong></td>
             <td class="row2">{user_gender}</td>
           </tr>


   5. To edit I added in member_editprofile the following (same info  as register_form)

   <tr>
            <td class="row1"><b>Gender</b></td>
            <td class="row1">
              <input type="radio" name="user_gender" value="Male"{user_gender} />
              Male&nbsp;&nbsp;&nbsp;
              <input type="radio" name="user_gender" value="Female"{user_gender} />
              Female</td>
          </tr>


When I test, it puts a number 1 in for male. When I edit and change it to female it is puts nothing (blank). Any help in simple terms would be appreciated (sorry I'm new to this).

Thanks
« Last Edit: February 25, 2008, 09:56:57 PM by bigwillhere »

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: radio button blues
« Reply #1 on: February 26, 2008, 02:06:32 AM »
Register form:

Code: [Select]
<tr>
            <td class="row1"><b>{lang_user_gender}</b></td>
            <td class="row1">
              <input type="radio" name="user_gender" value="0"{user_gender} />
              Male&nbsp;&nbsp;&nbsp;
              <input type="radio" name="user_gender" value="1"{user_gender} />
              Female</td>
          </tr>

edit profile:

Code: [Select]
<tr>
            <td class="row1"><b>{lang_user_gender}</b></td>
            <td class="row1">
              <input type="radio" name="user_gender" value="1"{user_gender} />
              Male&nbsp;&nbsp;&nbsp;
              <input type="radio" name="user_gender" value="0"{user_gender} />
              Female</td>
          </tr>

Note:

1 - Member page is get numeric value. No string in input value (same for additional image field). Is why is no work.
2 - You say: $lang['user_gender'] in db_field_definitions file so in member template - use: {lang_user_gender} .

;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline bigwillhere

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: radio button blues
« Reply #2 on: February 26, 2008, 05:35:03 AM »
Thank you so much :D

Offline karlo16

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: radio button blues
« Reply #3 on: September 04, 2008, 07:18:17 PM »
I have exactly the same problem  :(.
All I get is 1 instead of YES or nothing instead of NO. I have checked the code 100 times but I donīt see what is wrong.

In the database I added a field named "user_comm" to the "4images_users" table , type tinyint.


In member_profile.html:

Code: [Select]
<tr>
   <td class="row2"><b>{lang_user_comm}</b></td>
   <td class="row2">{user_comm}</td>
</tr>


In member_editprofile.html:

Code: [Select]

<tr>
    <td class="row2"><b>{lang_user_comm}</b></td>
    <td class="row2">
    <input type="radio" name="user_comm" value="1"{user_comm_yes} />
        {lang_yes}&nbsp;&nbsp;&nbsp;
     <input type="radio" name="user_comm" value="0"{user_comm_no} />
        {lang_no}
     </td>
</tr>


In db_field_definitions.php:

Code: [Select]
$additional_user_fields['user_comm'] = array($lang['user_comm'], "radio", 1);

Any help would be greatly appreciated.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: radio button blues
« Reply #4 on: September 05, 2008, 12:32:23 AM »
All I get is 1 instead of YES or nothing instead of NO.

Where do you get it? On the page or in the database? if in the database then its normal, because "tinyint" can only hold simple numbers.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline karlo16

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: radio button blues
« Reply #5 on: September 06, 2008, 12:05:51 PM »
Hi,
I donīt mean the entries in the database, I mean what I get on member_profile.html, where I have this code:

Code: [Select]
<tr>
   <td class="row2"><b>{lang_user_comm}</b></td>
   <td class="row2">{user_comm}</td>
</tr>

My understanding was that {user_comm} should result in a YES or a NO, depending on what the user selected on member_editprofile.html. Instead I get a 1 or a blank on that page.




Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: radio button blues
« Reply #6 on: September 06, 2008, 06:57:51 PM »
No, it doesn't work like that.
use this instead:
Code: [Select]
<tr>
   <td class="row2"><b>{lang_user_comm}</b></td>
   <td class="row2">{if user_comm}{lang_yes}{endif user_comm}{ifno user_comm}{lang_no}{endifno user_comm}</td>
</tr>
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline karlo16

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: radio button blues
« Reply #7 on: September 06, 2008, 11:09:30 PM »
Wow - thank you so much!  :D
It almost works - I only had to replace {lang_yes} and {lang_no} with YES and NO. No idea why - but anyway itīs working now.