여기에서 어디로 가야할 지 막혔습니다. 라디오 버튼에서 선택한 버튼의 값을 반환하고 싶습니다. 하지만 지금은 첫 번째 항목의 값만 반환합니다. 어떻게 모든 값을 반복 할 수 있을까요? 여기에 제 코드가 있습니다.선택 라디오 버튼
<!DOCTYPE html>
<html>
<body>
<?php include 'db_connector.php';
$result = mysqli_query($con,"SELECT name FROM os_scope");
while($row = mysqli_fetch_array($result)) {
$row['name'];
echo "<input type='radio' name='os' value=".$row['name']." id='myRadio'>";
}
?>
<p>Click the "Try it" button to display the value of the radio button.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myRadio").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
ID를 문서의 컨텍스트에서 고유해야합니다 ... –