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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:53:29+00:00 2026-06-08T08:53:29+00:00

I have a checkbox that calls a javascript function. When this checkbox is checked,

  • 0

I have a checkbox that calls a javascript function. When this checkbox is checked, other values in a form are auto filled out. The type of these other values are another checkbox and an option select field. I have the following in html:

<div id="NA" >
<input type="checkbox" name="remove_cd" value="r_on" id="r_on_cd" />N/A:
<select name="reason" id="reason_list">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<font color="#cc0000">Reason Required</font><hr/></div>

In javascript, I have the following in a function:

...
var y = document.getElementById("NA").children;
for(var i=0; i<y.length; y++){
    y[i].checked=true;
    y[i].options.selectedIndex=2;
}
...

I’m a little confused as to why this isn’t working. When I click on a checkbox in the form, the checkbox under the <div id="NA"> gets checked, but the option in the dropdown doesn’t get changed. Ideas?

  • 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-08T08:53:31+00:00Added an answer on June 8, 2026 at 8:53 am

    You have y++ instead of i++ in your loop. Try this

    for(var i=0; i<y.length; i++){
        y[i].checked=true;
        y[i].selectedIndex=2;
    
    }
    

    calling .selectedIndex on options throws Cannot set property 'selectedIndex' of undefined

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

Sidebar

Related Questions

I have a checkbox that when clicked, calls a javascript program that calls grid.PerformCallback(),
I have a JavaScript function that goes through a list of checked checkboxes and
I have a checkbox that when it is clicked it submits the form to
In my html.beginform I have this checkbox that I want to persist. I'm not
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
I have some JavaScript/jQuery code that watches for the changed event on a checkbox:
Strange question, I know. Allow me to explain. I have a JavaScript/jQuery function that
I have this javascript function: jQuery(document).ready(function() { FB.api('/me/friends', function(response) { if(response.data) { $.each(response.data,function(index,friend) {
I have a pie chart created with raphael. I have a form checkbox that
I have a checkbox that I do not want the user to have direct

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.