Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery dynamic input field on select option onchange
    text
    copied!<p>How can i poppulate the student name, roll and marks upon selecting the student subject based from select onchange event using jquery. Thank you so much.</p> <p>My views.py </p> <pre><code>def add_student(request): subject = Subject.objects.all() if request.method == "POST": obj = Student() obj.name = request.POST['name'] obj.roll = request.POST['roll'] obj.subject = Subject.objects.get(name = request.POST['subject']) obj.marks = request.POST['marks'] obj.save() var = RequestContext(request,{'title': ' Add Student','heading':'ADD STUDENT','subject':subject}) return render_to_response('student.html',var) </code></pre> <p>Here is my django template to add dynamic value to the student name , roll and marks textfield..</p> <pre><code>&lt;form action="." method="POST"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Subject&lt;/td&gt; &lt;td&gt; &lt;select id="subject" name= "subject"&gt; &lt;option value=""&gt;- - Select - -&lt;/option&gt; {% for i in subject %} &lt;option&gt;{{ i.name }}&lt;/option&gt; {% endfor %} &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Student Name&lt;/td&gt; &lt;td&gt; &lt;input id="name" type = "text" name ="name" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Student Roll&lt;/td&gt; &lt;td&gt; &lt;input id="roll" type = "text" name ="roll" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Marks&lt;/td&gt; &lt;td&gt; &lt;input id="marks" type = "text" name ="marks" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input id="save" type = "Submit" value="Submit" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/form&gt; &lt;/table&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload