Click here to Skip to main content
15,559,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
  <div class="form-check">
  <input class="form-check-input" type="radio" name="q1" id="q1a">
  <label class="form-check-label" for="q1a">
    A story teller
  </label>
</div>
<div class="form-check">
  <input class="form-check-input" type="radio" name="q1" id="q1b" >
  <label class="form-check-label" for="q1b">
    A problem solver
  </label>
</div>


What I have tried:

In the above code the name of the radio button is q1 which I can access by,


sq1 = request.POST.get('q1',"off") in views.py


but, I want to access it specifically by id 

so if I use 



w1a = request.POST.get('q1a',"off") it is giving me no value



HOW CAN I GET IT BY ONLY ID?
Posted
Updated 22-Nov-21 12:06pm

1 solution

You can't. Http POST passes the name and value of the input element, not the ID.
You need to use the value attribute to distinguish different buttons in a radio group.

See HTML input type="radio"[^]
 
Share this answer
 

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