Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2009
    Posts
    32
    Plugin Contributions
    0

    Default zen_draw_pull_down_menu, remember selected value

    i added a dropdown menu by using the zen_draw_pull_down function,
    $pulldown_array = array();
    $pulldown_array[] = array('id' => '0', 'text' => please select);
    $pulldown_array[] = array('id' => '1', 'text' => option a);
    $pulldown_array[] = array('id' => '2', 'text' => option b);
    zen_draw_pull_down_menu('pulldown', $pulldown_array)

    after i select "option a" and confirm the form, if other input field gets an error, the value of this dropdown goes back to "please select", i want to keep the dropdown value selected (make the value goes to "option a"), what do i do?

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: zen_draw_pull_down_menu, remember selected value

    pass the selected value as a parameter to the function call
    .

    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.

  3. #3
    Join Date
    Oct 2009
    Posts
    32
    Plugin Contributions
    0

    Default Re: zen_draw_pull_down_menu, remember selected value

    thanks, it does remember the selected value now

    another question, the dropdown shows option name ('text' => option a) on the page of site, but after submiting the form, i get option value ('id' => '1') in emaill, what do i get option name "option a" in email?

  4. #4
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Re: zen_draw_pull_down_menu, remember selected value

    In the code you're using to populate the email, you would want to display $pulldown_array['text'] instead of $pulldown_array['id'].

    HTH! :)
    [FONT="Verdana"]If you want something done right, you have to get Zenned.
    ♥~-My Zen Cart Mods-~♥[/FONT]

  5. #5
    Join Date
    Oct 2009
    Posts
    32
    Plugin Contributions
    0

    Default Re: zen_draw_pull_down_menu, remember selected value

    my code in tpl file:

    PHP Code:
    $pulldown_array = array();
    $pulldown_array[] = array('id' => '0''text' => please select);
    $pulldown_array[] = array('id' => '1''text' => option a);
    $pulldown_array[] = array('id' => '2''text' => option b);

    zen_draw_pull_down_menu('pulldown'$pulldown_array
    my code in header_php.php

    PHP Code:
    $my_email_text $pulldown
    if i select option a, i get the email content "1", but i want to get the email content "option a"

    if i change the code to
    $my_email_text = $pulldown_array['text']
    then i get nothing display in email

    any help?

  6. #6
    Join Date
    Oct 2009
    Posts
    32
    Plugin Contributions
    0

    Default Re: zen_draw_pull_down_menu, remember selected value

    i added another dropdown to the form,

    tpl file
    PHP Code:
    zen_get_country_list('country'$country'id="country") 
    header
    PHP Code:
    $my_email_text $ecountry
    i get "223" in email
    what do i get the text "United States" instead of the id "252" ?

  7. #7
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Re: zen_draw_pull_down_menu, remember selected value

    What is defining $pulldown? $pulldown and $pulldown_array aren't the same variables.

    You're collecting the displayed email data through a $_POST from the form. The value submitted through the form is "1", which is the key of the menu array, whereas "Option A" is the value of that key.

    Without seeing how you've set up $pulldown, you might try something like:

    PHP Code:
    if ($_POST['pulldown'] == '1') {
    $email_display 'Option A';
    } elseif (
    $_POST['pulldown'] == '2') {
    $email_display 'Option B';

    And so on.
    [FONT="Verdana"]If you want something done right, you have to get Zenned.
    ♥~-My Zen Cart Mods-~♥[/FONT]

  8. #8
    Join Date
    Oct 2009
    Posts
    32
    Plugin Contributions
    0

    Default Re: zen_draw_pull_down_menu, remember selected value

    thanks for your help, my pulldown finally works correctly

    but i'm not sure what do i make my country list pulldown display country name instead of country id
    there are hundreds of countries, do i have to add the code below?

    if ($_POST['country'] == '223') {
    $email_display = 'United States';
    } elseif ($_POST['country'] == '38') {
    $email_display = 'Canada';
    }
    ...

  9. #9
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: zen_draw_pull_down_menu, remember selected value

    There's already a built-in function to prepare the list of countries for a pulldown, as well as built-in logic for reading the value out and matching it with its corresponding name from the database. You'll find that logic in the sections of code that deal with address book handling and account creation.
    .

    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.

  10. #10
    Join Date
    Apr 2009
    Posts
    155
    Plugin Contributions
    1

    Default Re: zen_draw_pull_down_menu, remember selected value

    Again, without seeing how you're creating the email display, I would suggest trying to target the array value instead of the key.

    Maybe something like:

    PHP Code:
    foreach ($country_id as $id=>$country) {
    $email_display $country;

    Hope this helps. :)
    Last edited by ToniScraparoni; 16 May 2011 at 02:14 AM. Reason: Extra post - walked away and left my window open, didn't see DrB had replied. His answer is better, of course! :)
    [FONT="Verdana"]If you want something done right, you have to get Zenned.
    ♥~-My Zen Cart Mods-~♥[/FONT]

 

 

Similar Threads

  1. v152 Query returns no results if an id value is selected
    By eComEvo in forum General Questions
    Replies: 3
    Last Post: 12 May 2015, 03:07 AM
  2. v150 Question with zen_draw_pull_down_menu
    By jrcook416 in forum General Questions
    Replies: 11
    Last Post: 4 Dec 2012, 02:33 PM
  3. Display customer selected product attribute option and value in shopping cart
    By daedylus in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 24 Dec 2011, 04:30 PM
  4. zen_draw_pull_down_menu width
    By adamlonsdale in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 4 Jun 2010, 06:03 PM
  5. Replies: 2
    Last Post: 13 Jan 2010, 01:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg