Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8455645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:20:13+00:00 2026-06-10T12:20:13+00:00

I have been making a form in html that has a checkbox and if

  • 0

I have been making a form in html that has a checkbox and if checked it displays another checkbox using Javascript. I have now changed that form to use django’s Form library but I don’t know how to access the display attribute of the django input fields. I have tried the HideInput widget but all that doesn’t hide the label just the box itself.

Any help on how to set the display attributes of django Form objects and/or how to toggle those attributes using Javascript would be great and/or how to code event attributes on django Forms would be great!

models.py:

class ContactForm(forms.Form):
Contact = forms.BooleanField(required=False, widget=CheckboxInput())
More = forms.BooleanField(required=False, widget=CheckboxInput())

html page:

 <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
 <script type="text/javascript"> 




$(function(){
$('#id_Contact').click(function(){
 if($('#id_Contact').is(':checked')){
    $('#id_More').show();
 }
  });
});

    function ifChecked(id, id2){
        var ele = document.getElementById(id);
        var ele2 = document.getElementById(id2);

        if(ele.checked){
            ele2.style.display = "block";
        }
        else{
            ele2.style.display = "none";
        }
    }
</script>

<form action="/contact/" method="post">
{% for field in form %}
    <div class="fieldWrapper">
        {{ field.errors }}
        {{ field.label_tag }}: {{ field }}
    </div>
{% endfor %}
<p><input type="submit" value="Send message" /></p>
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:20:15+00:00Added an answer on June 10, 2026 at 12:20 pm

    You can do this.

    from django.forms import CheckboxInput, HiddenInput
    
    class ContactForm(forms.Form):
      Contact = forms.BooleanField(required=False, widget=CheckboxInput())
      More = forms.BooleanField(required=False, widget=HiddenInput())
    

    You could use jQuery

    $(function(){
      $('#id_Contact').click(function(){
         if($('#id_Contact').is(':checked')){$('#id_More').show();}
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using the Rails console a fair bit lately and its making
I am making a game that needs a crosshair. I have been playing with
I have been making components for Delphi for a couple months now. Currently I
I have an existing servlet that has a form and takes in data and
This topic has been covered in one form or another but none of the
Ok, so I have been working a Mysql class. I am making a form
Alright, I'm making a website using PHP/HTML, and I have some backend AJAX to
I have a HTML form asking for user input. A javascript function is meant
I have been making some research in the domain of servers for a website
For some time i have been making more or less little games. One level

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.