I have a drop-down list. After a user selects a language, the selected language is sent to the server. I want to show the selected values on the selected option button.
For example, a user selects a “de”, I wish “de'” is displayed on the form, instead of “en”.
How can I do this? Thanks
<form name="languages" method="post">
<select name="langSelect" onchange="">
<option>en (default)</option>
{% for ele in comments.languages.all %}
<option>{{ele.lang}}</option>
{% endfor %}
</select>
<div><a onclick="submitform()">Submit</a></div>
</form>
First off, why is your button not a Submit button? If it submits the form you should use
<input type="submit">Submit</input>If you use jQuery, then you can say:
I would put this in one statement but did it like this for clarity.
One other thing, you should use the id attribute as well/instead of just Name.