Skip to content
Advertisement

Getting the value of select option Django

Im been having a trouble how can I get the the value of my select option, I been using javascript to set the value of select option, below is my code which is returning the province value to number instead of text. The problem is how can I convert the number to text, is there any expert who share solution about this.

views.py

JavaScript

Select option – my reference link

JavaScript

javascript

JavaScript

Advertisement

Answer

You need to pass name value here newItem.value because on submit the option value attribute get passed to backend. Then after changing that still you need id to populate your next select-box so you can create custom attribute with value as id and then pass same to your function.

Demo code :

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement