複数のチェックボックス入力がHTMLフォーム内にある場合、jQuery(how to get multiple checkbox value using jquery)を使用してチェックボックスの値を取得できることを理解しています。いずれもフォーム内からチェックボックスの値を取得しません。htmlフォームから複数のチェックボックス値を取得する方法
私はフォームから値を抽出しようとしますが、チェックボックスの名前が値ではなく文書の中に現れる回数を数えるような奇妙な無線ノードリストを作成するだけです。
function validateForm() {
var checks = document.forms["TestForm"]["ParticipantSelection[]"];
alert(checks);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<form name="TestForm" action="Video1.php" method="post" onsubmit="return validateForm()">
<table>
<tr>
<th><img name="<?php echo $valueindicator[0];?>" src="<?php echo $all_four_images[0];?>" height="100">
</th>
<th><img name="<?php echo $valueindicator[1];?>" src="<?php echo $all_four_images[1];?>" height="100">
</th>
<th><img name="<?php echo $valueindicator[2];?>" src="<?php echo $all_four_images[2];?>" height="100">
</th>
</tr>
<tr>
<th> <input type="checkbox" name="ParticipantSelection[]" value="image1">
</th>
<th><input type="checkbox" name="ParticipantSelection[]" value="image2">
</th>
<th><input type="checkbox" name="ParticipantSelection[]" value="image3">
</th>
</tr>
</table>
<input type="hidden" name="AnswerCondition" value="BrowserCheckAnswer">
<button type="submit">Continue</button>
</form>
しかし、私はどのようにの値を取得するには、JSを取得するには考えているいただきまし代わりに何か他のものを数えるのフォーム入力、および確認の値にアクセスする方法がないアイデア内部ボックス
あなたは、その値をしたい場合は、何かに '.value'を使用してみてください。 'document.forms'と同じように。 – csmckelvey
こんにちは、お返事ありがとう!私はこれを数回試しました.HTMLチェックボックスの名前(これはデータを投稿する必要があります)のために未定義です。 –