Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello , I have quiz Project And I Created a view for the candidate to start the exam , the Questions And Answers Loaded Correctly but when I check Answer for First Question and Select the answer in the Next Question the first question reset , it's like All the question are one Question

here is my HTML CODE

<pre>        <div class="col-12">
            @foreach (var Item in Model)
            {
                <p class="fw-bold">@Item.Question</p>
                @foreach (var Answer in Item.Answers)
                {
                    <div>
                        <input type="radio" name="box" id="@Answer.Id">
                        <label for="@Answer.Id" class="box">
                            <div class="course">
                                
                                 @Answer.Answer 
                            </div>
                        </label>


                    </div>
                }
            }
        </div>


What I have tried:

I tried some solution but it's not working and it's hard to search for this problem in google
Posted
Updated 4-Oct-22 1:05am

1 solution

That's what radio buttons do. You click one and it resets the previously selected one in the radio button group. If you want to have them independent, use checkboxes. All of your radio buttons are in a group called 'box' (via your name="box" attribute).
 
Share this answer
 
Comments
Abdulmajeed Alotaibi 4-Oct-22 7:15am    
thanks a lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900