Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quantity Drop Downs


PupStar

Recommended Posts

sorry guys I am having another bad day, accomplished a lot today but now really annoyed with myself as I can not even get my head around such a simple thing tonight.

 

I need to transform this:

 

	  case 'PRODUCT_LIST_BUY_NOW':
	    if (tep_not_null($listing['products_price'] > '0')) {
	    $prod_list_contents .= '<td width="20%" align="center">' . TEXT_QTY . ' <input type="text" name="add_id['.$number_of_products.']" value="" size="2"></td>';
	    $prod_list_contents .= '<input type="hidden" name="products_id['.$number_of_products.']" value="'.$listing['products_id'].'"></td>';
	    }else{
	    $prod_list_contents .= ' ';
	   }
	   break;

 

so it uses the tep_draw_pull_down_menu function.

 

Hope someone can set me right tonight w00t.gif

 

Thanks

 

Mark

Link to comment
Share on other sites

ok I got this far and it creates the dropdown but without any values

 

$prod_list_contents .= '<td width="20%" align="center">' . TEXT_QTY . ' ' . tep_draw_pull_down_menu('add_id['.$number_of_products.']', $number_of_products) . tep_draw_hidden_field('products_id['.$number_of_products.']', $listing['products_id']) . '</td>';

 

I know that the second argument is probably incorrect, just not sure what to replace it with lol

 

Thanks

 

Mark

Link to comment
Share on other sites

ok nearly there. I have now built the array and populated the dropdown with values using

 

	   for ($i=0; $i<20; $i++) {
	    $qty_array[] = array('add_id' => $i+1, 'text' => $i+1);
	   }
	   $prod_list_contents .= '<td width="20%" align="center">' . TEXT_QTY . ' ' . tep_draw_pull_down_menu('add_id['.$number_of_products.']', $qty_array, 1) . tep_draw_hidden_field('products_id['.$number_of_products.']', $listing['products_id']) . '</td>';

 

However the dropdowns values keep repeating e.g.

 

dropdown 1 = 1,2,3

dropdown 2 = 1,2,3,1,2,3

dropdown 3 = 1,2,3,1,2,3,1,2,3

 

etc etc etc.

 

Mark

Link to comment
Share on other sites

ok finally got it sorted with a the help of google and an old post by spooks.

 

This is what I have:

 

	    $qty_array=array();
	    $qty_array[] = array('id' => '00', 'text' => 'select');
		 for($i=1; $i<=20; $i++){
		  if(strlen($i)!= 1){
		   $j = '' . $i;
		  } else {
		   $j = $i;
		  }
	    $qty_array[] = array('id' => $j, 'text' => $j); }
	    $prod_list_contents .= '<td width="20%" align="center">' . TEXT_QTY . ' ' . tep_draw_pull_down_menu('add_id['.$number_of_products.']', $qty_array, $i) . tep_draw_hidden_field('products_id['.$number_of_products.']', $listing['products_id']) . '</td>';

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...