0
<body>
    <form action="" method="post">
      {% csrf_token %}
      <input type="radio" name="course" value="C" />C
      <br>
      <input type="radio" name="course" value="CPP" />CPP
      <br>
      <input type="radio" name="course" value="DS" />DS
      <br>
    </form>
    {{res}}
</body>

views.py

def user(request):
   if 'CPP' in request.POST:
          print("CPP")
          return HttpResponseRedirect(request.path_info)

Is there any solution to pass values to the views when the radio button is checked when submit button is not there

Ajay
  • 89
  • 6

1 Answers1

0

Pretty sure you're going to have to use some JavaScript for this.

I would add event listeners to each of your inputs, then on change, send the event.target.value to your view. Haven't done this before personally but think you would have to look into an XMLHttpRequest or a fetch

Smurphy
  • 70
  • 6