한 페이지에 여러 양식이 있습니다. 모두 다음과 같습니다. ID 값은 변경되지만 옵션은 비슷할 수 있습니다.Jquery 라디오 버튼 양식 제출
<form class="test"><td>4000</td>
<td align='center'><input type='radio' name='radio' value='car' checked></td>
<td align='center'><input type='radio' name='radio' value='boat' ></td>
<td align='center'><input type='radio' name='radio' value='Plane' ></td>
<input type='hidden' name='id' value='4000'/>
<input type='hidden' name='location' value='local'/>
<div class="form" style="display: none;">
</div></form>
JQuery를 사용하여 3 개의 라디오 버튼 중 하나를 선택하면 제출하려고합니다.
<script>
$("input[name='radio']").click(function() {
var CurrectForm=$(this).parents('.test:first');
$.post(
'do.php',
CurrectForm.serialize(),
function(response) {
CurrectForm.find('#form').html(response);
show(response);
}
);
});
</script>
나는 위와 비슷한 체크 박스와 드롭 다운 목록을 사용했다. 그러나 이것은 do.php 페이지에 값을 제출하는 것처럼 보이지 않습니다. 제출 된 값은 div 형식으로 표시됩니다. var_dump($_POST);
을 수행하면 빈 배열이됩니다.
누군가 나를 올바른 방향으로 안내 할 수 있습니까? 감사합니다.
양식을 변경하면 이것이 작동하는 것 같습니다.
<td><form class="test">
<input type='radio' name='radio' value='car' checked>
<input type='radio' name='radio' value='boat' >
<input type='radio' name='radio' value='Plane' >
<input type='hidden' name='id' value='4000'/>
<input type='hidden' name='location' value='local'/>
<div class="form" style="display: none;">
</div></form></td>
왜 원인이 변경 되나요?
Jfiddle 작업 예 :)으로 http://jsfiddle.net/QvpH5/
당신이 그것을 제대로 선택하는 경우'console.dir (CurrectForm가)'볼을 시도 해 봤나 :이 jsFiddle에서
봐는 수정 (변경 .parents .parent하기)를 참조하십시오? – JoeCortopassi