radio버튼으로 value 값을 받는 방법..
본문
<body>
<form action="mixProcess.php" method="post">
<div class="area-container">
<br><br>
<legend>원하는 선크림 타입을 선택해주세요</legend>
<br>
<input type="radio" name="type" value="physical" /> 무기자차
<input type="radio" name="type" value="chemical" /> 유기자차
</div>
<br>
<legend>주로 활동하는 장소를 선택해주세요</legend>
<br>
<input type="radio" name="area" value="inside" /> 실내
<input type="radio" name="area" value="outside" /> 실외
</div>
<br><br>
<div class="next-botton">
<button type="submit" class="join-button">다음선택</button>
라디오 버튼으로 둘 중 하나를 선택하는 질문 두가지를 조합해서 거기에 맞게 html를 띄워주고싶은데요 ㅠ( 2x2 총 4가지의 경우의 수)
라디오버튼 value값을 어떻게 받아서 처리를 해야 if 문으로 조합 할 수 있나요?
form action = mixProcess.php 에 어떻게 라디오 value값을 넣고 어떻게 분기처리를 해야할까요?ㅜㅜ
!-->
답변 1
* mixProcess.php
$type = $_POST['type'];
$area = $_POST['area'];
if ($type == '무기자차' && $area == 'inside') {
echo 'a';
} else if ($type == '무기자차' && $area == 'outside') {
echo 'b';
} else if ($type == '유기자차' && $area == 'inside') {
echo 'c';
} else if ($type == '유기자차' && $area == 'outside') {
echo 'd';
}
답변을 작성하시기 전에 로그인 해주세요.