2010-05-18 7 views
0

여러 제품 선택을 지원하도록 수정하려는 장바구니 스크립트가 있습니다. 지금과 같이 고객은 단일 드롭 다운 메뉴에서 제품을 선택할 수 있습니다. 이제 여러 드롭 다운 메뉴를 추가하고 싶습니다 (모두 동일한 옵션으로 채워짐).다중 드롭 다운 메뉴를 지원하도록 PHP 장바구니 수정

if($eshopoptions['options_num']>1){ 
      $opt=$eshopoptions['options_num']; 
      $replace.="\n".'<label for="eopt'.$theid.'"><select id="eopt'.$theid.'" name="option">'; 
      for($i=1;$i<=$opt;$i++){ 
       $option=$eshop_product['products'][$i]['option']; 
       $price=$eshop_product['products'][$i]['price']; 
       if($option!=''){ 
        if($price!='0.00') 
         $replace.='<option value="'.$i.'">'.stripslashes(esc_attr($option)).' @ '.sprintf(_c('%1$s%2$s|1-currency symbol 2-amount','eshop'), $currsymbol, number_format($price,2)).'</option>'."\n"; 
        else 
         $replace.='<option value="'.$i.'">'.stripslashes(esc_attr($option)).'</option>'."\n"; 
       } 


      } 

출력 코드를 얻기의 정말 간단한 방법이 있나요 메뉴가 3 번 대신 한 번 말 : 여기

드롭 다운 메뉴를 출력하는 PHP는 무엇입니까? 당신이 정말로 중복을 필요로하지 않는

답변

0

것은, 당신은 사용자가 추가하여 여러 옵션을 선택할 수 있습니다 및, 선택적으로, 크기가 선택 태그 속성을 여러 :이 솔루션을 선택하는 경우

if($eshopoptions['options_num']>1){ 
     $opt=$eshopoptions['options_num']; 
     $replace.="\n".'<label for="eopt'.$theid.'"><select id="eopt'.$theid.'" name="option" multiple="multiple" size="'.$opt.'">'; 
     for($i=1;$i<=$opt;$i++){ 
      $option=$eshop_product['products'][$i]['option']; 
      $price=$eshop_product['products'][$i]['price']; 
      if($option!=''){ 
       if($price!='0.00') 
        $replace.='<option value="'.$i.'">'.stripslashes(esc_attr($option)).' @ '.sprintf(_c('%1$s%2$s|1-currency symbol 2-amount','eshop'), $currsymbol, number_format($price,2)).'</option>'."\n"; 
       else 
        $replace.='<option value="'.$i.'">'.stripslashes(esc_attr($option)).'</option>'."\n"; 
      } 


     } 
+0

것은, 당신이 할 수 있습니다 ctrl 키를 누른 상태에서 여러 옵션을 클릭하여 여러 옵션을 선택하는 방법에 대한 지침을 추가하십시오. – DBruns

관련 문제