Site maintenance: Sun 15 Nov, from 12:00 UTC, about 4–6 hours. Details

This cutover relies on some testing that is still incomplete so may be cancelled at short notice

Forums / Templates, Stylesheets, Page Layout / help, need custom dropdowns and checkboxes

help, need custom dropdowns and checkboxes

Locked

Started by cpk on 5 Jun 2006, 4:22 PM · Views: 2,523

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
5 Jun 2006, 4:22 PM
#1
cpk avatar

cpk

New Zenner

Join Date:
Apr 2006
Posts:
37
Plugin Contributions:
0

help, need custom dropdowns and checkboxes

I have searched the forum, the wiki and gone to wit's end attempting to build my own drop down menu based on some of the recommendations I was able to find but apparently I am too dense to figure this out.

I am trying to create some drop down form menus and checkboxes in a survey form. These drop downs will not need to make any calls to the database or write to the db. The form is to be emailed to the admin once it is filled out. The form is on its own page.

I based my first attempts on DrByte's "band sign up" form but it has no drop down menus, check boxes or radio button examples. I could build this form with html but I would like to take advantage of zen-cart's built-in error handling.

I have been trying to decipher the zen_draw_pull_down_menu and zen_draw_checkbox_field functions but do not have enough php skill (yet!) to figure out how to use them.

Can someone help me with this or point me to a tutorial/explanation on how to implement these functions.

Thanks,

cpk

6 Jun 2006, 5:19 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: help, need custom dropdowns and checkboxes

Hopefully this will help get you started in the right direction:

in your header_php.php, you need something like this:

// do you want to set a default selection?  if not, use '0':
$default_pulldown_selection = '2';

//For validation, you're looking for the contents of the $_POST['my_pulldown_menu'] variable
// this is only set after "submit" is clicked.
$pulldown_selected_item = (isset($_POST['my_pulldown_menu'])) ? $_POST['my_pulldown_menu'] : $default_pulldown_selection ;


//build an array of entries to be displayed on the template:
    $pulldown_contents[] = array('id'=>'0', 'text'=>'Please Select');
    $pulldown_contents[] = array('id'=>'1', 'text'=>'Choice Number 1');
    $pulldown_contents[] = array('id'=>'2', 'text'=>'Choice Number 2');
    $pulldown_contents[] = array('id'=>'3', 'text'=>'Choice Number 3');
    $pulldown_contents[] = array('id'=>'4', 'text'=>'Choice Number 4');
    $pulldown_contents[] = array('id'=>'5', 'text'=>'Choice Number 5');


// you could add some validation here.
if ($pulldown_selected_item==0) { 
  $messageStack->add_session('header','Please select an option from the pulldown menu','error');
}

In your template, display the contents:```php
echo zen_draw_pull_down_menu('my_pulldown_menu', $pulldown_contents, $pulldown_selected_item);

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Jun 2006, 7:56 PM
#3
aspudden avatar

aspudden

Zen Follower

Join Date:
Dec 2004
Location:
Stockholm
Posts:
113
Plugin Contributions:
0

Re: help, need custom dropdowns and checkboxes

This was nice ..
Now I have to find out how Radio Buttons works in Zen..

Asp :-D

Employing version 1.3.X

14 Jul 2006, 1:02 PM
#4
mfp avatar

mfp

New Zenner

Join Date:
Mar 2006
Posts:
19
Plugin Contributions:
0

Re: help, need custom dropdowns and checkboxes

i used this method to create a dropdown menu but the pulldown_contents are not displaying. any suggestions?

7 Jun 2007, 11:35 PM
#5
handcrafteduk avatar

handcrafteduk

Zen Follower

Join Date:
Jul 2006
Posts:
240
Plugin Contributions:
0

Re: help, need custom dropdowns and checkboxes

in your header_php.php, you need something like this:

I'm confused. Is this in:

/public_html/includes/templates/MYTEMPLATE/common

Thanks.