1

I'm trying to pass the answers from multiple dropdown menus like this one to a single button to answer question for a user. Any advice is very much appreciated.

<script lang="text/JavaScript">
    
        function myFunction(){
            //variables
            var firstClass = document.getElementById("class1").value;
            console.log(firstClass);

            if(firstClass == Yes) {
                firstClass = true;
            }
            
            else {
                firstClass = false;
            }

        }
            
   </script>
<form id="collegeGrad">
        <p>Have you completed CLASS 1?</p>
        <label>First Class</label>
        <select id="class1">
            <option value="Yes">Yes</option>
            <option value="No">No</option>
        </select>

Currently the program says that "Yes" is not defined?

1

1 Answer 1

0

You missed the quotes on the first If statement. It should have been like this ==> if (firstClass == 'Yes') {firstClass = true;}

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.