2011-08-17 2 views
0

form_dropdown?私はCodeIgniterのコード点火装置を使用してドロップダウンボックスでのオプションを無効にする方法

 echo "<tr class='background1'><td class='checkoutfield'>"; 
     $countryall=''; 
     $select=''; 
     if(isset($order)) $country=$order['varShippingCountry']; else $country=''; 
     if(isset($countries) && $countries !='') { 
      $countryall['']="Select"; 
     foreach($countries as $key=>$value): 
     $countryall["226/United States"]="United States"; 
     if($value['id'] !='226') { 
//<option value=”spider” disabled=”disabled”>Spider</option> 
     $countryall['0']="-------------------------------------------------------"; 
$countryall["$value[id]/$value[varPrintableName]"]=$value['varPrintableName']; 

     } 
     if($value['id'] == $country) 
     $select="$value[id]/$value[varPrintableName]"; 
     endforeach; 
     } 
      $selFunc='style="width:190px;" id="varShippingCountry" class="required" onchange="stateajax(this.value)" onKeyup="return changeText(\'varShippingCountry\',\'varPaymentCountry\',\'this.value\')"'; 
     echo form_label('Country','varShippingCountry')."<span class='mandatory'>*</span></td><td>"; 

エコーform_dropdown(「varShippingCountry」、$このドロップダウンで「------」値を無効にしたいですcountryall、$ selFunc);

答えて

0

HTML選択要素内の項目を無効にすることはできません。要素全体を無効にするだけです。

リストの異なるセクション間にセパレータを作成しようとしていますか?その場合、<optgroup>を使用できます。

<select> 
    <optgroup label="Swedish Cars"> 
    <option value="volvo">Volvo</option> 
    <option value="saab">Saab</option> 
    </optgroup> 
    <optgroup label="German Cars"> 
    <option value="mercedes">Mercedes</option> 
    <option value="audi">Audi</option> 
    </optgroup> 
</select> 

これは多次元配列を渡すことでCodeIgniterで行うことができます。

また、最初とデフォルトの項目を------のように見せようとしている場合は、通常の方法で空の値で追加します。次に、検証時に空の値が渡されていないことを確認します。

関連する問題