Author Topic: Checkboxes on Registration Form  (Read 6022 times)

harmony

  • Beginner
  • *
  • Posts: 32
Checkboxes on Registration Form
« on: May 01, 2006, 17:30:54 pm »
Dear VirtuMart,

I've added several checkboxes to the Registration form.  If I click the checkboxes as a new registrant, they insert into the database just fine.  However, when I go to the account.billing file as a user to edit the registration, the checkboxes I checked on registration aren't checked.  Is there an easy way to make the checkboxes stay checked once the user has registered and wants to edit the registration form?

Thanks a million!

harmony

  • Beginner
  • *
  • Posts: 32
Re: Checkboxes on Registration Form
« Reply #1 on: May 04, 2006, 05:14:51 am »
I know it can take some time to get back to these posts, but I hope someone can help me with this.

I also know that a new registration manager will be included in the next release.  Please hurry!

 ;)

Thanks


Orur

  • Beginner
  • *
  • Posts: 3
Re: Checkboxes on Registration Form
« Reply #2 on: May 04, 2006, 11:19:34 am »
Quote
<input type="checkbox" name="remember" id="mod_login_remember" class="inputbox" value="yes" />
         <label for="mod_login_remember">

This is taken from the login form, but im sure the code is the same for leaving nuttons/tickboxes with a selected value

"value=yes=" should leave it ticked at all times untill turned off and saved

hope this helps

harmony

  • Beginner
  • *
  • Posts: 32
Re: Checkboxes on Registration Form
« Reply #3 on: May 04, 2006, 16:03:10 pm »
Hi Orur,

Thanks for the reply!  The code you wrote would work to keep a checkbox checked, but that's not exactly what I'm trying to do.  Here's the scenario:

On the registration form, I've added 6 checkboxes for the registrant to enter ethnicity information.  The checkboxes are:

1. African-American/Black/African/non-Hispanic
2. Asian-American/Asian/South Asian/Southeast Asian/Pacific Islander
3. European American/MiddleEastern American/White/non-Hispanic
4. Latino/Hispanic/Puerto Rican/Mexican-American
5. American Indian/Alaskan Native
6. Decline to Answer

The user is allowed to check more than 1 box.  When they submit the registration now, their choice(s) can be seen in the mysql database (the choice is being inserted correctly into the database).  However, when the user goes to edit their registration, using the "Account Information" link that takes them to the "account.billing" page, their choices for ethnicity do not stay checked (all the boxes are unchecked).  If they click the "SAVE" icon at the top, without re-checking their selection(s), the ethnicity info is deleted from the mysql database.

Is there a way to dynamically save the state of their checkboxes.  Whatever they selected during the initial registration will remain checked in the account information page and then if they want to edit their selection, then can uncheck what they selected originally, check something else, click save and the results will register correctly to the database.

This is the code from checkout_register_form.php that applies to these checkboxes:

Near the top:

Code: [Select]
// Ethnicity Info
$shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_PHPSHOP_USER_FORM_ETHNICITY;
$shopper_fields['africanamerican'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_AFRICANAMERICAN;
$shopper_fields['asianamerican'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ASIANAMERICAN;
$shopper_fields['europeanamerican'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_EUROPEANAMERICAN;
$shopper_fields['latino'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_LATINO;
$shopper_fields['nativeamerican'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_NATIVEAMERICAN;
$shopper_fields['declinetoanswer'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_DECLINETOANSWER;
$shopper_fields[uniqid('fieldset_end')] = "";


Later in the file where the field and its contents are printed:

Code: [Select]
case 'africanamerican':
echo '<input type="checkbox" name="africanamerican" value="African-American/Black/African/non-Hispanic">African-American/Black/African/non-Hispanic</input>';
break;
case 'asianamerican':
echo '<input type="checkbox" name="asianamerican" value="Asian-American/Asian/South Asian/Southeast Asian/Pacific Islander">Asian-American/Asian/South Asian/Southeast Asian/Pacific Islander</input>';
break;
case 'europeanamerican':
echo '<input type="checkbox" name="europeanamerican" value="European American/MiddleEastern American/White/non-Hispanic">European American/MiddleEastern American/White/non-Hispanic</input>';
break;
case 'latino':
echo '<input type="checkbox" name="latino" value="Latino/Hispanic/Puerto Rican/Mexican-American">Latino/Hispanic/Puerto Rican/Mexican-American</input>';
break;
case 'nativeamerican':
echo '<input type="checkbox" name="nativeamerican" value="American Indian/Alaskan Native">American Indian/Alaskan Native</input>';
break;
case 'declinetoanswer':
echo '<input type="checkbox" name="declinetoanswer" value="Decline to Answer">Decline to Answer</input>';
break;


Here is the code from account.billing.php (the file that displays the registration form for the user to edit):


Near the top

Code: [Select]
$shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_PHPSHOP_USER_FORM_ETHNICITY;
$shopper_fields['africanamerican'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_AFRICANAMERICAN;
$shopper_fields['asianamerican'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ASIANAMERICAN;
$shopper_fields['europeanamerican'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_EUROPEANAMERICAN;
$shopper_fields['latino'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_LATINO;
$shopper_fields['nativeamerican'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_NATIVEAMERICAN;
$shopper_fields['declinetoanswer'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_DECLINETOANSWER;
$shopper_fields[uniqid('fieldset_end')] = "";



Later in the file where the fields and contents are printed:

Code: [Select]
case 'africanamerican':
echo '<input type="checkbox" name="africanamerican" value="African-American/Black/African/non-Hispanic">African-American/Black/African/non-Hispanic</input>';
break;
case 'asianamerican':
echo '<input type="checkbox" name="asianamerican" value="Asian-American/Asian/South Asian/Southeast Asian/Pacific Islander">Asian-American/Asian/South Asian/Southeast Asian/Pacific Islander</input>';
break;
case 'europeanamerican':
echo '<input type="checkbox" name="europeanamerican" value="European American/MiddleEastern American/White/non-Hispanic">European American/MiddleEastern American/White/non-Hispanic</input>';
break;
case 'latino':
echo '<input type="checkbox" name="latino" value="Latino/Hispanic/Puerto Rican/Mexican-American">Latino/Hispanic/Puerto Rican/Mexican-American</input>';
break;
case 'nativeamerican':
echo '<input type="checkbox" name="nativeamerican" value="American Indian/Alaskan Native">American Indian/Alaskan Native</input>';
break;
case 'declinetoanswer':
echo '<input type="checkbox" name="declinetoanswer" value="Decline to Answer">Decline to Answer</input>';
break;


Thanks again for your help

harmony

  • Beginner
  • *
  • Posts: 32
Re: Checkboxes on Registration Form
« Reply #4 on: May 16, 2006, 04:13:14 am »
Anyone willing to have a look at this.  It seems like an easy fix.

Thanks for any help!

Harmony

rxalex

  • Beginner
  • *
  • Posts: 34
Re: Checkboxes on Registration Form
« Reply #5 on: May 16, 2006, 05:04:42 am »
Anyone know how I can Move the state below city on registration form?
Help You Help Me :)

Bigjohn

  • Jr. Member
  • **
  • Posts: 191
Re: Checkboxes on Registration Form
« Reply #6 on: May 16, 2006, 18:55:32 pm »
Not a layout customization question - Moving to the right forum category.

To the original poster:  you need to read that data back in before you generate the form.

rxalex

  • Beginner
  • *
  • Posts: 34
Re: Checkboxes on Registration Form
« Reply #7 on: May 16, 2006, 19:01:59 pm »
where can I get an answer?
Help You Help Me :)

harmony

  • Beginner
  • *
  • Posts: 32
Re: Checkboxes on Registration Form
« Reply #8 on: May 17, 2006, 02:36:13 am »
Hi BigJohn,

Thanks for the reply!  I'm not sure what you meant by this:

"To the original poster:  you need to read that data back in before you generate the form."

What do you mean by "read that data back in?"

Thanks