웹 개발에 특히 익숙합니다. 특히 jQuery라고 부르면 jQuery로 벽돌 벽에 부딪혔습니다.jquery 여러 라디오 버튼 선택에 대한 요소 표시/숨기기
내가 가지고있는 것은 양식 (선택 목적)과 일련의 페이팔 버튼입니다. 수행해야 할 기능은 표시/숨기기이지만 세 가지 라디오 버튼 중 특정 선택이 선택된 경우에만 표시/숨기기입니다. 세 가지 조합 선택은 해당 페이팔 버튼을 표시하거나 숨기는 것입니다.
단일 양식 라디오 선택으로 표시하거나 숨길 수 있지만 조합에는 표시되지 않습니다.
내가 아직 초보자인데 내 양배추 코딩을 변명해야한다. 코드가 더 최적화 될 수있다. 다행히도 트래픽이 적은 사이트/작은 시장 일 뿐이다. 누구든지 할 수있는 사람에게는 큰 기쁨이다. 도와주세요.
모든 버튼을 잘 숨길 수있었습니다.
<script type="text/javascript">
$(document).ready(function(){
//Hide div w/id extra
$("#button1,#button2,#button3,#button4,#button5,
#button6,#button7,#button8,#button9,#button10,
#button11, #button12, #button13, #button14,#button15,
#button16,#button17,#button18,#button19,#button20,
#button21,#button22,#button23,#button24,
#button25,#button26,#button27").css("display","none");
});
</script>
아래 스크립트는 다음 형태의 HTML에게 있습니다
<form action="order-lamb" method="post" id="order">
<input type="hidden" name="pack" value="whole" />
<div class="form-item leg option left2">
<h3> Choose from the following Leg options</h3>
<p>Choose what leg options you would like:</p>
<label for="leg-one-of-each"><input type="radio" name="leg" value="each" id="leg-one-of-each" />1 x Carvery and 1 x Butterfly Legs</label>
<p class="or">OR</p>
<label for="leg-both-carvery"><input type="radio" name="leg" value="carvery" id="leg-both-carvery" />2 x Carvery Legs</label>
<p class="or">OR</p>
<label for="leg-both-butterfly"><input type="radio" name="leg" value="butterfly" id="leg-both-butterfly" /> 2 x Butterfly Legs</label>
</div>
<div class="form-item loin option right2 ">
<h3> Choose from the following Loin options:</h3>
<p>Choose what loin options you would like:</p>
<label for="loin-one-of-each"><input type="radio" name="loin" value="loin-each" id="loin-one-of-each" />1 x Nolsette Loin and 1 x Backstrap & Tenderloin</label>
<p class="or">OR</p>
<label for="loin-both-nolsette"><input type="radio" name="loin" value="nolsette" id="loin-both-nolsette" />2 x Nolsette Loins </label>
<p class="or">OR</p>
<label for="loin-both-backstrap"><input type="radio" name="loin" value="backstrap-tenderloin" id="loin-both-backstrap" />2 x Backstrap & Tenderloins </label>
</div>
<div class="cf"></div>
<div class="form-item shoulder option left2">
<h3>Choose from the following Shoulder options:</h3>
<p>Choose what shoulder option you would like:</p>
<label for="shoulder-one-of-each"><input type="radio" name="shoulder" value="shoulder-each" id="shoulder-one-of-each" /> 1 x Bone and Rolled and 1 x French Danish</label>
<p class="or">OR</p>
<label for="shoulder-both-bone-and-rolled"><input type="radio" name="shoulder" value="bone-and-rolled" id="shoulder-both-bone-and-rolled" />2 x Bone and Rolled</label>
<p class="or">OR</p>
<label for="shoulder-both-french-danish"><input type="radio" name="shoulder" value="french-danish" id="shoulder-both-french-danish" />2 x French Danish</label>
</div>
<div class="form-item included right2">
<h3>You will also get:</h3>
<p>These are included:</p>
<span class="choice selected">2 x Fully Frenched Racks </span>
<p class="or">AND</p>
<span class="choice selected">1 x Coastal Spring Lamb Mince Pack </span> </span>
<p class="or">AND</p>
<span class="choice selected">1 x Coastal Spring Lamb Patty Pack</span> </span>
</div>
<div class="clear"></div>
<div class="align-right" />
<div class="form-item submit">
<p class="error">You must select an option in each category.</p>
<input type="image" name="submit" src="images/buttons-and-logos/awaiting-payment.png" id="submit" border="0" />
<p class="paypal">You will receive a confirmation email when your payment has been processed via paypal. <br />Price includes freight and GST.<br /></p>
</div>
</form>
'id'의 목록 대신에, 모든 버튼에'class'를 주어야합니다. – KRyan
어떤 조합으로 어떤 버튼이 표시 될 예정입니까? 네가하려는 일을 정말로 모르겠다. – KRyan
저는 지금 ID를 사용했습니다. 세 가지 라디오 옵션 3 세트, 로컬 농장에서 고기를 주문하기위한 것, 다리 옵션 용 세트, 허리 절단 옵션 용 두 번째 세트 및 어깨 컷 용 세 번째 세트 선택권. 고객은 각 세 세트의 선택 항목을 클릭해야하며, 조합에 따라 제출 버튼은 해당 상품을 해당 페이팔 체크 아웃 페이지로 안내합니다. – spikeyheadedfreak