*sure, here is my code*. please let me know how can I modify this to achieve a dependent drop fields. I want it to make action on executive_authority, next fields should pop-up
*Views.py* **** from django.shortcuts import render, redirect from er_form.forms import NewClientForm, BillingGroupForm from django.template.context_processors import csrf def index(request): context = {} return render(request, 'er_form/index.html', context) def client(request): if request.method == 'POST': client_form = NewClientForm(request.POST) billing_form = BillingGroupForm(request.POST) #saving the instance if client_form.is_valid() and billing_form.is_valid(): form = client_form.save() bform = billing_form.save(commit=False) #to create relatnshp between 2forms,dont save just collect instance bform.form = form #creating rltnshp between two forms bform.client_id=1 bform.save() #saving both forms return redirect('client') else: client_form = NewClientForm() billing_form = BillingGroupForm() args = {} args.update(csrf(request)) args['client_form'] = client_form args['billing_form'] = billing_form return render(request, "er_form/client.html", args) **** *models.py* **** from __future__ import unicode_literals from django.utils import timezone from django.db import models from datetime import datetime, date, timedelta from django.core.validators import RegexValidator # Create your models here. #New Client model class NewClient(models.Model): #choices for selection status_choice = [ ('active', 'Active'), ('inactive', 'In-Active'), ] #User Input Feilds business_name = models.CharField(max_length=1024, help_text='Enter Your Business Name') legal_name = models.CharField(max_length=1024, help_text='Enter Legal Name, if different from the Business') nature_of_business = models.CharField(max_length=1024) years_in_business = models.PositiveIntegerField(default=0) company_type = models.CharField(max_length=20) #Data provided by Tool to reflect in Database association_name = models.CharField(max_length=20, default='OCIBP') group = models.CharField(max_length=30, default='', null=True) code = models.CharField(max_length=10, default='000') status = models.CharField(max_length=15, choices=status_choice, default='active') anniversery_date=models.DateTimeField(default=datetime.now()+timedelta(days=365)) service_rep = models.CharField(max_length=50, default='Carolina') sales_person = models.CharField(max_length=50, default='Robert Perusco') renewal_agent = models.CharField(max_length=50, default='Merit Ontario') first_billing_period = models.DateField(auto_now_add=True) created_on = models.DateField(auto_now=True) created_by = models.DateField(null=True) last_updated_on = models.DateField(null=True) last_updated_by = models.DateField(null=True) current_state = models.CharField(max_length=15, default='open') original_service_date = models.DateField(auto_now_add=True) cert_length = models.PositiveIntegerField(null=True) cert_start = models.DateField(null=True) require_pin = models.CharField(max_length=15, null=True) require_alt_pin = models.CharField(max_length=15, null=True) def __str__(self): return self.business_name #BillingGroup Model class BillingGroup(models.Model): client = models.ForeignKey(NewClient) name = models.CharField(max_length=1024, default='Administration Fee') billing_type = models.CharField(max_length=1024, default='Per Person Charge') remit_to = models.CharField(max_length=1024, default = 'BSL') language = models.CharField(max_length=50, default='English') legacy_system_code = models.CharField(max_length=20, null=True) carrier_division_code = models.CharField(max_length=20, null=True) invoice_override = models.CharField(max_length=20, null=True) address_1 = models.CharField("Address line 1",max_length=1024,) address_2 = models.CharField("Address line 2",max_length=1024,) city = models.CharField("City",max_length=1024,) province = models.CharField("Province",max_length=30,) country = models.CharField("Country", max_length=30) zip_code = models.CharField("ZIP / Postal code",max_length=12,) first_name = models.CharField("First Name", max_length=30, ) last_name = models.CharField("Last Name", max_length=30,) title = models.CharField("Title/Position", max_length=1024) email = models.EmailField("Authorized - Email", max_length=254) phone_regex = RegexValidator(regex=r'^\+?1?\d{9,15}$', message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.") phone_number = models.CharField(validators=[phone_regex], max_length=17, blank=True) # validators should be a list fax = models.CharField(max_length=30, null=True) send_notification = models.BooleanField(default=True) executive_authority = models.CharField(verbose_name = "Is This Person also has Signing Authority", max_length=15,) exec_first_name = models.CharField("Executive First Name", max_length=30, ) exec_last_name = models.CharField("Executive Last Name", max_length=30,) exec_title = models.CharField("Executive Title/Position", max_length=1024) exec_email = models.EmailField("Executive - Email", max_length=254) exec_phone_regex = RegexValidator(regex=r'^\+?1?\d{9,15}$', message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.") exec_phone_number = models.CharField("Executive Phone Number",validators=[phone_regex], max_length=17, blank=True) exec_fax = models.CharField("Fax number",max_length=30, null=True) payment_type = models.CharField(max_length=30) institution_code = models.CharField(max_length=30) branch_number = models.CharField(max_length=30) account_number = models.CharField(max_length=30) withdraw_day = models.DateField(null=True, blank=True) federal_tax_province = models.CharField(max_length=30, default="Ontario") def __str__(self): return self.client **** *client.html* ****** {% extends 'er_form/index.html' %} {% block content %} <div class="container"> <div class="form-group"> <form method="POST"> {% csrf_token %} {{ client_form.as_p }} {{ billing_form.as_p }} <button type="submit" class="btn btn-primary">Submit</button> </form> </div> </div> {% endblock content %} ****** *urls.py* ***** from django.conf.urls import url from er_form import views urlpatterns = [ url('', views.client, name="client"), ] ***** I am combining two model forms into a single HTML template. Please have a look AZIZ sir On Sun, Jun 7, 2020 at 11:53 AM AMINE AZIZ <a.amine...@gmail.com> wrote: > You 'll use JQUERY normal as the same in html > > You need every html id (so you cab add on change) > > JQUERY on change select > Show hidden popup / or show hidden input > > Share your code. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/45f6db02-6231-4e49-b97a-93565012abf9o%40googlegroups.com > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPcTzRZpY%3DSkHdnvNLa0q6PO%3DxTUuWh6ARZY6y5ic9y6N4Q1Fw%40mail.gmail.com.