so i want to make a dependent select box , but im still beginner and want to try with the old way
The point is , the first dropdown is the database name (schema in dbeaver) and the second dropdown is list of table name that the database has
html code
<div class="form-group">
<label class="control-label col-md-3">Table Name</label>
<div class="col-md-4">
<div class="input-group bootstrap-timepicker">
<div class="btn-group">
<select style="width:425px;background-color:white;height:30px;font-color:red;text-align-last:center;">
<!-- <li><a href="#"></a></li> -->
{% for table_name in obj %}
<option>{{ table_name.table_name }}
{% endfor %}
<!-- <li><a href="#">Dropdown link</a></li> -->
</option>
</select>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Column Name</label>
<div class="col-md-4">
<div class="input-group bootstrap-timepicker">
<div class="btn-group">
<select style="width:425px;background-color:white;height:30px;font-color:red;text-align-last:center;">
<!-- <li><a href="#"></a></li> -->
*here where i want to put the data after i select the first select above*
<!-- <li><a href="#">Dropdown link</a></li> -->
</option>
</select>
</div>
</div>
</div>
</div>
Havent put the post and get for the first select dropdown to send the parameter *dont know where
views.py
#for the first dropdown
def list_all_table(request):
obj = TableAll.objects.all()
context = {
'obj' : obj
}
return render(request,'define_segment.html',context)
#for the second dropdown form after you select the first dropdown
def list_all_table2(request):
#need to get parameter first but how
dsn_tns = cx_Oracle.makedsn('IP', 'PORT', sid)
conn = cx_Oracle.connect(user=r ' ', password=' ', dsn=dsn_tns)
c = conn.cursor()
c.execute("SELECT table_name FROM ALL_TABLES WHERE owner ='"+ variable from firstdropdown +"'")
for row in c:
#to insert the data in second select dropdown
return render(request,'define_segment.html',context)
models.py
import datetime
from django.db import models
from django.utils import timezone
class TableAll(models.Model):
table_name = models.CharField(max_length=250)
0001_init.py
from django.db import migrations, models
from django.contrib.auth.models import User
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
role = models.CharField(max_length=250)
role.contribute_to_class(User,'role')
operations = [
migrations.CreateModel(
name='TableAll',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('table_name', models.CharField(max_length=250)),
],
),
]
Maybe someone can help me with this, thankyou for the help !