2016-09-14 36 views
0

現在我有這種形式。輸入類型無線標籤中的多個值

<div class="col-sm-4"> 

    <div class="radio"> 
     <label> 
      <input type="radio" name="hairstyle" id="optionsRadios1" value="Lang">Lang 
     </label> 
    </div> 

    <div class="radio"> 
     <label> 
      <input type="radio" name="hairstyle" id="optionsRadios2" value="Kort">Kort 
     </label> 
    </div> 

    <div class="radio"> 
     <label> 
      <input type="radio" name="hairstyle" id="optionsRadios3" value="Kaal">Kaal 
     </label> 
    </div> 

</div> 

當您單擊第二個按鈕時,您將獲得value Kort。但是每個選項都花費不同的時間,所以有可能給它另一個值,例如15?我試過{'style':'min','kort':'15'},kort|15kort,15但它不工作。還是有一些我不知道的laravel內建的東西?

+1

不明白你需要什麼 – koe

+0

我只想爲每個選項得到兩個值。 – twoam

+0

爲什麼不使用複選框?無線電盒僅返回1 – koe

回答

0

爲什麼不只是使用Kort|15之類的東西,然後在控制器中打破這兩個值?既然你在談論Laravel,我猜測幕後(和你的文章)你有一個處理數據的控制器。因此,你可以這樣做:

public function store(Request $request) 
{ 
    ... 
    $hairstyle = $request->input('hairstyle'); 
    $values = explode('|', $hairstyle); 
    $name = $values[0]; //This will be Kort 
    $cost = $values[1]; //This will be 15 
    ... 
} 
相關問題