Reputation: 319
I am developing an app with django. Here is the screenshot. I need to know when user will select on a plan in the next page that plan radio button should auto select.
I am able to grab all the information regarding the selected plan but dont understand how to select that plan's radio button.
here is the screenshots. Let me know anyone has the answer.
here is the next image where the radio buttons are present.
Upvotes: 0
Views: 335
Reputation: 571
You could store the selected plan inside a sessions key and then check if that key exists in the next page... something like:
# in your first view set the session keys of posted plan
if 'express' in request.POST:
request.session['express'] = 'express chosen' # strings are easier to handle
# add the other plans to the if statement
# in the next page's view function, add keys to context if they are in the session framework like so
if 'express' in request.session:
express = request.session['express']
# add the other plans to the if statement
Now in the template, check if the variables exist to select option as default...
<input type="radio" {%if express%}checked{%endif%}>
<label>Express</label>
<!-- repeat for the other plans -->
Upvotes: 1