<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function dropfunc(){
var s = document.getElementsByName('parameters')[0];
var text = s.options[s.selectedIndex].text;
document.getElementById("mytext").value = text;
document.getElementById("distance").value = text;
}
</script>
<form action="/summarize_text/" method="post" enctype="multipart/form-data">
{% csrf_token %}
<p><b> Text Summarizer</p></b>
<select name = "parameters">
<option>Sentence1</option>
<option>Sentence2</option>
<option>Sentence3</option>
<option>Sentence4</option>
</select>
<input type="button" onclick="dropfunc()" value="Submit">
<input type="text" id="mytext">
<div class="fieldWrapper">
<label id="distance">Sentence</label>
{{form.text_data}}
</div>
</form>
</body>
</html>
In this code the textbox mytext is responsive to changes in the dropdown but the dropfunc() should make changes in the django form variable distance as well. Please suggest what I am doing wrong. In forms.py I have defined text data as follows:
text_data = forms.CharField(max_length=20000000, widget=forms.Textarea())
labelelement has novalueproperty. and anoptionelement has notextproperty ... perhaps you're looking forelement.textContent?