Zen Cart Logo
Forums / General Questions / Radion Button Checked for Contact Page

Radion Button Checked for Contact Page

Views: 728

Results 1 to 8 of 8
1 Oct 2013, 2:34 PM
#1
eyeb avatar

eyeb

New Zenner

Join Date:
Aug 2013
Location:
United States
Posts:
37
Plugin Contributions:
0

Radion Button Checked for Contact Page

Hello,

I've customized my Contact page with additional fields (here is a great link for instructions on that - http://www.zen-cart.com/showthread.php?149814-extra-text-field-in-contact-us-form) and have added some radio buttons. I have four items to select from - Architect, Consumer, Designer, Purchasing Agent. It seems by default Purchasing Agent is always selected - I want to keep this list alphabetical but have Consumer be the one that is selected...how can I do that? Sorry I can't share the link to the store yet (in development).

Here is part of the code from the tpl_contact_us_default.php file that has the radio buttons:

<label class="m-wrap" for="job">Occupation:</label>
<?php echo zen_draw_radio_field('job', 'Architect', 'id="Architect"') . '    '. 'Architect' . '<br/>' . zen_draw_radio_field('job', 'Consumer', 'id="Consumer"'). '    '. 'Consumer' . '<br/>' . zen_draw_radio_field('job', 'Designer', 'id="Designer"'). '    '. 'Designer' . '<br/>'  . zen_draw_radio_field('job', 'Purchasing Agent', 'id="Purchasing"'). '    '. 'Purchasing Agent' . '<br/>' ?>
<br class="clearBoth" /><br/>
1 Oct 2013, 3:39 PM
#2
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Radion Button Checked for Contact Page

eyeb:

Hello,

I've customized my Contact page with additional fields (here is a great link for instructions on that - http://www.zen-cart.com/showthread.php?149814-extra-text-field-in-contact-us-form) and have added some radio buttons. I have four items to select from - Architect, Consumer, Designer, Purchasing Agent. It seems by default Purchasing Agent is always selected - I want to keep this list alphabetical but have Consumer be the one that is selected...how can I do that? Sorry I can't share the link to the store yet (in development).

Here is part of the code from the tpl_contact_us_default.php file that has the radio buttons:

<label class="m-wrap" for="job">Occupation:</label>

<?php echo zen_draw_radio_field('job', 'Architect', 'id="Architect"') . '    '. 'Architect' . '<br/>' . zen_draw_radio_field('job', 'Consumer', 'id="Consumer"'). '    '. 'Consumer' . '<br/>' . zen_draw_radio_field('job', 'Designer', 'id="Designer"'). '    '. 'Designer' . '<br/>' . zen_draw_radio_field('job', 'Purchasing Agent', 'id="Purchasing"'). '    '. 'Purchasing Agent' . '<br/>' ?>

<br class="clearBoth" /><br/>



try:
<?php echo zen_draw_radio_field('job', 'Architect', **'',** 'id="Architect"') . '    '. 'Architect' . '<br/>' . zen_draw_radio_field('job', 'Consumer', **$checked = true,** 'id="Consumer"'). '    '. 'Consumer' . '<br/>' . zen_draw_radio_field('job', 'Designer', **'',** 'id="Designer"'). '    '. 'Designer' . '<br/>'  . zen_draw_radio_field('job', 'Purchasing Agent', **'',** 'id="Purchasing"'). '    '. 'Purchasing Agent' . '<br/>' ?>
1 Oct 2013, 3:46 PM
#3
eyeb avatar

eyeb

New Zenner

Join Date:
Aug 2013
Location:
United States
Posts:
37
Plugin Contributions:
0

Re: Radion Button Checked for Contact Page

Sorry about the title...Radio Button, of course.

I have a follow up question too - is there way so that NO option is selected as the default?

1 Oct 2013, 3:48 PM
#4
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Radion Button Checked for Contact Page

eyeb:

Sorry about the title...Radio Button, of course.

I have a follow up question too - is there way so that NO option is selected as the default?

try:

<?php echo zen_draw_radio_field('job', 'Architect', **'',** 'id="Architect"') . '    '. 'Architect' . '<br/>' . zen_draw_radio_field('job', 'Consumer', **'',** 'id="Consumer"'). '    '. 'Consumer' . '<br/>' . zen_draw_radio_field('job', 'Designer', **'',** 'id="Designer"'). '    '. 'Designer' . '<br/>' . zen_draw_radio_field('job', 'Purchasing Agent', **'',** 'id="Purchasing"'). '    '. 'Purchasing Agent' . '<br/>' ?>
1 Oct 2013, 3:49 PM
#5
eyeb avatar

eyeb

New Zenner

Join Date:
Aug 2013
Location:
United States
Posts:
37
Plugin Contributions:
0

Re: Radion Button Checked for Contact Page

Thanks for the reply Rbarbour - didn't work - nothing changed.

1 Oct 2013, 3:54 PM
#6
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Radion Button Checked for Contact Page

eyeb:

Thanks for the reply Rbarbour - didn't work - nothing changed.

Zen function for radio buttons:

function zen_draw_radio_field($name, $value = '', $checked = false, $parameters = '') {

so leaving '', should auto return false on those radio buttons.

I tried and it worked on my dev site,

I also tried changing true to false and that worked - none were selected

Even changed $checked = false to just 'true', - and that worked

1 Oct 2013, 3:54 PM
#7
eyeb avatar

eyeb

New Zenner

Join Date:
Aug 2013
Location:
United States
Posts:
37
Plugin Contributions:
0

Re: Radion Button Checked for Contact Page

IT WORKED...thanks. My apologies - I didn't see that you had also included the '', for the other entries too -- AND it also worked to show none of them selected. Great stuff...thanks again!

1 Oct 2013, 4:22 PM
#8
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Radion Button Checked for Contact Page

eyeb:

IT WORKED...thanks. My apologies - I didn't see that you had also included the '', for the other entries too -- AND it also worked to show none of them selected. Great stuff...thanks again!

Glad you got it working!