为什么判断是否选择了radio的函数没有用?



if($_COOKIE['userRight']!= 'normalRight'){ 
    header('location:./loginPage.php');
    exit();
}
require_once('../dataBase.php');
$sql = "SELECT diseaseName FROM foodMedicineDataBase";//php的双引号里面可以放变量
$result = $conn->query($sql);

?>
html>
<html>
<head>
<title>
浏览常见疾病的目录
title>
<meta charset="utf-8">

<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />

head>
<body>
<form action='chooseSyndrome.php' method='get' onsubmit="return isCheckedFunc()">

if($result->num_rows>0){
    //echo $result->num_rows; 读取未重合之前的元素数量
    while($row=$result->fetch_assoc()) {
        $resultArray[]=$row['diseaseName'];//将结果集转换为数组
        
        }
}
$resultArrayUnique=array_unique($resultArray);//获取了不重复的数组
$resultLenth=count($resultArrayUnique);//获取了数组的长度,便于后面遍历
//echo $resultLenth;读取重合之后的元素数量
for($i=0;$i<$resultLenth;$i++){
    echo "$resultArrayUnique[$i]>$resultArrayUnique[$i]";
    //echo var_dump($resultArrayUnique);这段代码是用来查看输出结果
}

?>
<br>
<br>
<input type="submit" value="查询">
form>
<script>
function isCheckedFunc(){
    var theRadioInputs=document.getElementsByName('diseaseName');
    var raidoIsChecked=0;
    for(let m=0; mlength; i++){
        if(theRadioInputs[m].checked){
        raidoIsChecked=1;        
        }    
    }
    if (radioIsChecked==1) {
        return true;
        
    }else{
    alert("您还没有选择");
    return false;
    }

}
script>
body>
html>


    var raidoIsChecked=0;

这里写错了,不过计算统一改为了 radioIsChecked ,仍然还是不行哦

还有一个错误

    for(let m=0; m<theRadioInputs.length; i++){

这里应该是 m++
程序员真的需要心细如发,现在可以了!