...

View Full Version : problem with multiple drop down null value



sackstein
11-05-2010, 12:59 AM
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:


<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:


<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?

angst
11-05-2010, 01:50 AM
google is your friend!

set the $default value.


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/

sackstein
11-05-2010, 06:59 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum