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 8380791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:32:48+00:00 2026-06-09T16:32:48+00:00

I have a working javascript file that adds and removes check boxes and drop

  • 0

I have a working javascript file that adds and removes check boxes and drop down lists on an html page using the element ID tag. I would like to apply the javascript code to a form that is being generated by a django app. I have tried to hide a field by changing the javascript element ID as follows,

id1.style.visibility = 'hidden';

to match an element on the form that is being generated by django but the javascript isn’t taking effect and the field is still visible.

In my django template html file, I have included the js file from the site that is being served up by django.

<head>
   <script type="text/javascript" src="/static/js/submitform.js"></script>
   <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>

I can see in the template page source code the js file as above and can click on the link and see the javascript code. So I know the javascript file is contained within the template.

I have done something similar with my css file and that takes effect on the template page, however I can’t get the javascript to apply correctly.

I’ve been struggling with this for a while now and haven’t done this before. Can anyone provide help or know of any documentation that I can read which shows me how to do this?

Sorry if this isn’t an appropriate question but haven’t done this before and I am just stuck on this.. The project I am working on is for an internal test site so I am not worried at the moment about compressing the js file to the client or any injections that I could be exposed to.. Just getting an understanding how to do this.!

Thanks – Oli

  • 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-09T16:32:49+00:00Added an answer on June 9, 2026 at 4:32 pm

    you can do it like this:

    #html
    {% block main-menu %} 
        <br>
        <br>
        Click here to play with username
        <button id="show_button">show</button>
        <button id="hide_button">hide</button>
        <br>
        <br>
        <script type="text/javascript">
            $(function() {
                    $("#show_button").click(function() {
                        $("#id_username").show();
                    });
                    $("#hide_button").click(function() {
                        $("#id_username").hide();
                    });
            });
        </script>
        <div class="contentarea">
            <form method="post" action="">{% csrf_token %}
                {{ reg_form.as_p }}
                <input type="submit" value="register" />
            </form>
        </div>
    
    #forms.py
    class RegistrationForm(forms.Form):
        username = forms.CharField(label="Username", max_length=30)
        email = forms.EmailField(label="Email")
        password = forms.CharField(label="Password", widget=forms.PasswordInput())
        password2 = forms.CharField(label="Password (Again)", widget=forms.PasswordInput())
    
    Here your clean methods and so on
    

    Django will automatically create an id for your fields like id_yourfield.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML file that is using Javascript to do file I/O operations
I have been working on a project that dynamically creates a javascript file using
I am working on a web page that pulls an external javascript file that
I have an external JS file that I load into my HTML <script type=text/javascript
I have been working on this JavaScript file so that as someone types in
I have some JavaScript(1.7.2) in an external .js file that's working ok. But after
I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
I have a javascript function, that works fine if it's anonymous but stops working
I have some code that was working one month ago... now, when I check
I have an web application that is a JavaScript file will the following line

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.