Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2009
    Posts
    160
    Thanks
    40
    Thanked 1 Time in 1 Post

    Question problem with multiple drop down null value

    I am using oscommerce for a shopping cart site and I am having a problem on a page that requires 2 drop downs. they are for sizing on a garment.

    There needs to be 2 drop downs one for regular sizes and one for tall and the user has to pick between the two. I have this working now but the initial value of each drop down is not something like "please select one" it is the actual price for both so that is causing a conflict because there is no way to just choose one.

    What I ended up trying to do was add in a null value to be initially selected on both drop downs with text saying "please select one"

    here is the original:

    Code:
      <tr>
                  <td class="option_names"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
                  <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>
                  </tr>
    And here it is modified to initially display the please select text:

    Code:
      <tr>
                  <td class="option_names"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
                  <td class="main"><?php
    			if ($products_options_name['products_options_id'] = 2 ) { 
    			    echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', array_merge(array(array('id'=>null, 'text'=>'Please Select One '. $selected_attribute)), $products_options_array)); 
    				}
    			else { 
    			  echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); 
    					}			
    				?></td>
                  </tr>
    The problem oscommerce is having with this is that when the user tries to add to his cart, it ends up showing no sizing for both and just taking the null value i suppose.

    Is there anything I can do to avoid this?

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    google is your friend!

    set the $default value.
    PHP Code:
     261  // Output a form pull down menu
     
    262    function tep_draw_pull_down_menu($name$values$default ''$parameters ''$required false) {
     
    263      $field '<select name="' tep_output_string($name) . '"';
     
    264  
     265      
    if (tep_not_null($parameters)) $field .= ' ' $parameters;
     
    266  
     267      $field 
    .= '>';
     
    268  
     269      
    if (empty($default) && isset($GLOBALS[$name])) $default stripslashes($GLOBALS[$name]);
     
    270  
     271      
    for ($i=0$n=sizeof($values); $i<$n$i++) {
     
    272        $field .= '<option value="' tep_output_string($values[$i]['id']) . '"';
     
    273        if ($default == $values[$i]['id']) {
     
    274          $field .= ' SELECTED';
     
    275        }
     
    276  
     277        $field 
    .= '>' tep_output_string($values[$i]['text'], array('"' => '&quot;''\'' => ''', '<' => '&lt;', '>' => '&gt;')) . '</option>';
     278      }
     279      $field .= '
    </select>;
     
    280  
     281      
    if ($required == true$field .= TEXT_FIELD_REQUIRED;
     
    282  
     283      
    return $field;
     
    284    


    also when dealing with prebuilt software like OSCommerce, your much better off using the right forum: http://forums.oscommerce.com/
    Last edited by angst; 11-05-2010 at 02:52 AM.

  • #3
    Regular Coder
    Join Date
    Jan 2009
    Posts
    160
    Thanks
    40
    Thanked 1 Time in 1 Post
    The only value you can set as default is one of the id numbers. You can't set a default text value or anything. So I can set the default to be any of my attributes.

    I know I should probably post in the oscommerce forums but whenever I post anything that is not a really standard feature I get no replies.


  •  

    Posting Permissions

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