2014-09-26 5 views
-2

라디오 버튼 대신 사용할 수있는 것은 무엇입니까? 때문에 PHP 페이지에 1 개 이상의 값을 전달해야합니다.입력에 둘 이상의 값을 전달하는 방법은 무엇입니까?

<table width="900" border="0" align="center" cellpadding="2" cellspacing="0" id='center'> 
       <tr class="row_submit"> 
        <td><input type="radio" name="carrier" <?php if (isset($carrier) && $carrier=="LBC") echo "checked";?> value="LBC"></td> 
        <td><img src="../paymentoptions/LBC.jpg" alt="LBC" class="picture"/></td> 
        <td><p>The Shipping takes 1-2 days for NCR and 2-3 days for any provincial. Payment method is through BPI Bank Deposit.<p> 
         <div id='price'> Additional ₱250 </div></td> 

       </tr> 
       <tr class="row_submit"> 
        <td><input type="radio" name="carrier" <?php if (isset($carrier) && $carrier=="PickUp") echo "checked";?> value="PickUp"></td> 
        <td><img src="../paymentoptions/Pick-up.jpg" alt="Pick-Up" class="picture"/></td> 
        <td><p>Personally pick up your merchandise at our office. Free of Charge. Office hours: 10:00 am to 5:00 pm<p> 
         <div id='price'> Free!! </div></td> 
       </tr> 
      </table> 

여기 내 코드입니다. $ payment에 값을 전달해야합니다. 이는 약간 다르지만 사전 정의되어 있습니다.

예를 들어, 나는 LBC이고 LBC는 LBC이고 $ payment는 BPI입니다.

그래서 양식을 클릭 할 때 라디오 버튼을 대체 할 수있는 것은 무엇입니까? 또한 행을 누를 때 자동으로 제출할 jquery를 추가했습니다.

답변

0

질문에 따라 잘 모르겠지만 논리를 통해 양식을 제출할 때 PHP로 해결할 수 있습니까?

if($_POST['carrier'] == 'LBC'){ 
    //then payment has to be BPI correct? 
} 

두 개 이상의 지불 옵션이있는 것은 아닙니다.

양식에 두 번째 입력이 필요하면 LBC 용 라디오를 클릭 할 때 결제 수단을 표시해야 jquery를 사용하여 설정할 수 있습니다. 보내려는 다른 값이 미리 정의 된 경우

<input type="hidden" name="payment" value=""/> 

다음 JQuery와에

$('input[name=carrier]').click(function(){ 
    if ($(this).is(':checked')){ 
     $('input[name=payment]').val('BPI'); 
    } 
}); 
0

, 당신은 선택에 숨겨진 필드를 채울 수있는 숨겨진 필드를 사용하여 자바 스크립트를 사용 할 수 있습니다

<input type="hidden" name="payment" value="" /> 

와 jQuery를에

(당신이 jQuery를 필요는 없지만 당신이 그것을 언급)

$(document).ready(function() { 
    $(input:radio[name=shipping]).change(function(){ 
     if ($(input:radio[name=shipping]).val() === 'X') { 
      $(input:radio[name=payment]).val('Y'); 
     } 
    }) 
} 
관련 문제