0

Now the form is one form, here is the new broken code

    <script language="javascript" type="text/javascript">
function verifyIt(){
    if((document.form1.baseline_08.value != "" && Number(document.form1.baseline_08.value) &&  document.form1.baseline_08.value != "-1")){
    if((document.form1.baseline_09.value != "" && Number(document.form1.baseline_09.value) &&  document.form1.baseline_09.value != "-1")){
        document.form1.submit();
        return true;
    }else{
        alert("Please select how old you were when you started smoking every day.");
        return false;
    }
}
function submit2(){
    document.form1.direction.value = "back";
    document.form1.submit();
}

</script>

Now the verify doesnt work at all. I just dont see what is wrong with this now.

The problem I am having is the form1 is the only one being recognized. I believe it is because of my if statement structure. Basicly I only get the return from the form1. What is wrong with my js?

4

1 に答える 1

1

それは私のif文の構造によるものだと思います。

はい、returnチェックした後は常に ingform1です。ただし、一度に複数のフォームを送信することはできませんので、1 つにまとめてください。次に使用します

function verifyIt() {
    if(!(document.form.baseline_08.value == "" && Number(document.form.baseline_08.value) &&  document.form.baseline_08.value != "-1")){
        alert("Please select how old you were when you started smoking every day.");
        return false;
    }
    if(!(document.form.baseline_09.value != "" && Number(document.form.baseline_09.value) &&  document.form.baseline_09.value != "-1")){
        alert("Please select when you would smoke after waking up.");
        return false;
    }
    document.form.submit();
}
于 2013-02-13T20:25:25.780 に答える