2016-11-19 1 views
0
  1. 내 컨트롤러 코드 :foreach 루프의 각 라디오 버튼의 값을 가져

    $model = customer::all(); 
    return View::make('admin.test.startTest') 
    ->with('title','Question and answer') 
    ->with('data',$model); 
    
  2. 이 내보기 코드 :

    foreach($data as $value) { 
    ?>   
    <p>{{ $value-> Qid }}) 
    {{ $value-> opt }} 
    </p>  
    <?php   
    if(($value ->QuestionType) == "MCQ") 
    {?> 
    <ul> 
        <li><b>A: </b>{{$value->opt1}}</li> 
        <li><b>B: </b>{{$value->opt2}}</li> 
        <li><b>C: </b>{{$value->opt3}}</li> 
        <li><b>D: </b>{{$value->opt4}}</li> 
    </ul> 
    Select one of the following options:<br> 
    <input type="radio" name="answers[{{ $value-> opt }}]" value="A" ">{{   $value->opt1}}<br> 
    <input type="radio" name="answers[{{ $value-> opt }}]" value="B" ">{{ $value->opt2}}<br> 
    <input type="radio" name="answers[{{ $value-> opt }}]" value="C" ">{{ $value->opt3}}<br> 
    <input type="radio" name="answers[{{ $value-> opt }}]" value="D" ">{{ $value->opt4}}<br> 
    <?php } elseif(($value ->QuestionType) == "truefalse") {?> 
    Select one of the following options:<br> 
        <input type="radio" name="answers[{{ $value-> opt }}]" value="true" ">True<br> 
        <input type="radio" name="answers[{{ $value-> opt }}]" value="false" ">False<br> 
    <?php } else {?> 
    <input type="radio" name="answers[{{ $value-> opt }}]" value="ok" ">OK<br> 
    <input type="radio" name="answers[{{ $value-> opt }}]" value="agree" ">Agree<br> 
    

    • 내가 laravel를 사용했다
    • 내가 모든 값이
    • 는 어떻게 입력 필드의 값을 얻을 수있는 결과와 비교 싶어 데이터베이스에서 데이터를 검색
    • for 루프의 입력 필드 a
    • 어디에서 입력 필드 값을 얻을 수 있습니까?

    • 문제는 내가 값이 표시되는 각 루프에서 라디오 버튼을 넣어 왔지만되어 선택된 값

답변

0

을받지 당신은 이름과 몇 가지와 라디오 버튼을 인쇄해야 클래스이 아래 실시 예에서 여기

nameclass 같은 selectRAge을 촬영 한 것이 샘플 인 HT JQuery와 통해 확인으로 ml의

버튼을 선택 위의 코드 기본에
<input type="radio" name="Age" class="selectR" value="23">23 
<input type="radio" name="Age" class="selectR" value="24">24 
<input type="radio" name="Age" class="selectR" value="25">25 
<input type="radio" name="Age" class="selectR" checked value="26">26 
<input type="radio" name="Age" class="selectR" value="27">27 

24 설정 26

입니다

$(".selectR[value='24']").prop('checked',true); 

당신이 라디오 버튼 값을 선택 얻을하려면

$(".selectR").each(function(){ 
     if($(this).prop("checked")){ 
      console.log($(this).val()); //24 will console 
     } 
    }); 
관련 문제