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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:20:17+00:00 2026-05-16T15:20:17+00:00

I have a form field (a series of checkboxes) that’s being created dynamically from

  • 0

I have a form field (a series of checkboxes) that’s being created dynamically from a database, so it’s possible that the field will not exist on the form (if there are no matching values in the database). I have some code that needs to execute based on whether the field exists, and pull in the values that are selected if it does exist. I can’t seem to get javascript to acknowledge that this field exists, though. Here’s what I’ve tried:

function displayAction(){
    var f = document.adminForm;
    var a = f.action;

    if(f.prefix.value!="-") {
        a = a + '&task=callExclusionDisplay&prefix=' + f.prefix.value;
    }
    else {
        var exclusions = document.getElementById("exclusions");
        if (exclusions != null){
            alert("exclusions set");
            a = a + '&task=callExclusionCreate&prefix=' + f.prefix.value + '&exclusions=' + exclusions.join();
        }
    }
    alert('after if, action is ' + a);
}

The code never passes the if statement checking to see if exclusions is not null, even though when I look at the page there are a number of checkboxes named exclusions (with the id also set to exclusions). Is the issue with !=null because it’s a group of checkboxes, rather than a single form element? How can I get this to work? If I skip the test for null, the code throws errors about exclusions not being defined if the database doesn’t return any matching values.

  • 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-05-16T15:20:18+00:00Added an answer on May 16, 2026 at 3:20 pm

    You’re using document.getElementById, but form elements have a name.
    Try f.elements.namedItem("exclusions") instead of exclusions != null

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

Sidebar

Related Questions

I have a form with a hidden Came from Adwords field that will be
I have an information request form that has a series of checkboxes that i
I have a form field: web_address = forms.RegexField(regex=r'^DO SOMETHING$', error_messages = {'invalid': _(Not a
I have a dijit.form.NumberTextBox input field that starts out with these parms: new dijit.form.NumberTextBox({
I have a form and one of the fields is a check-all-that-applies type field
I have form and form text field which generates dynamically using JSP. And I'm
I have a form field that uses some Javascript to format user input 'price'
I have a form on a simple web page that has a series of
I have a form field that contains one , or several Complete email addresses.
I have a form dynamically created using Jquery and i am trying to validate

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.