I'm implementing an HTML table that is populated with information as the page is rendered. I cannot use a form here but still, I need to embed some common input controls to certain s in that HTML table (selection boxes).
So I think the data itself can be passed to the template as the page is being rendered but do I need to use javascript to fill the controls? I think I cannot use anything related to forms here.
I have implemented a javascript ajax code to get the data when the table is filled by a user. That is working perfectly. But the user does not fill everything on that table but there must be some selections done before the data can be submitted. That data is read from the database, delivered to the HTML table for the user to make a selection.
But I have never used HTML inputs other than in Django forms.
Or is there a better solution to achieve this?
Edit: As the code that is given here as an answer is used the dropdown content of the selection control, it contains two classes as attributes: dropdown-content and select-dropdown. I changed the z-index in order to bring the dropdown box to the top. It did open but the container did hide the dropdown items inside it. So I made a test and by setting z-index to be large enough and the dropdown content came front. I have not used z-index before so please forgive me if I have done something funny here.
.dropdown-content {
z-index: 33;
position: relative;
}
.select-dropdown {
z-index: 32;
position: relative;
}
if your data form model, you can use return data to html, like this:
views.py
def articleCreate(request):
categrays = Categray.objects.all()
context = {'categrays':categrays}
return render(request, 'article/articleCreate.html', context)
and use {% for %} add your data to html.
<div class="categray">
<label>Categray:</label><br>
<select name=categray>
{% for categray in categrays %}
<option value={{categray.id}}>{{ categray.name }}</option>
{% endfor %}
</select>
</div>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments