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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:33:24+00:00 2026-06-09T06:33:24+00:00

I am trying to create a select tag that holds values in it and

  • 0

I am trying to create a select tag that holds values in it and if two out of the five values are selected another select box will show on the screen. I have tried searching for this and found where people are using javascript and using the onchange event but for some reason I cannot get it to work. The toggle id is the one I want to show up if individual or short term is selected if not I want it to be hidden. The code is below and thanks for your help in advance. I didn’t include the javascript because I deleted it all but I have tried it a few different ways with no luck. I am thinking it is the way I have the form laid out.

HTML

<tr>                        
   <td class='txt'><span>&#42;</span>Coverage Needed?</td>  
<td>
   <select name="ins_type" id='ins_options' onChange="toggle();">
     <option>Select...</option>                             
     <option value="Group">Group Insurance</option>
     <option value="Individual">Individual Insurance</option>
     <option value="Short Term">Short Term Insurance</option>                                   
     <option value="Medicare">Medicare</option>
     <option value="Life">Life Insurance</option>   
   </select>                
</td>                                   
<td ><div id='toggle'><span>&#42;</span>How Many?
   <select name='applicants' id='applicants' >                                      
      <option>Select...</option>
      <option value='1'>1</option>
      <option value='2'>2</option>
      <option value='3'>3</option>
      <option value='4'>4</option>
      <option value='5'>5</option>
      <option value='6'>6</option>
      <option value='7'>7</option>
      <option value='1'>8</option>
      <option value='9'>9</option>
      <option value='10'>10</option>    
   </select>
  </div>
  </td>             
</tr>

Javascript (I was thinking something like this should work)

<script type="text/javascript">
  function toggle() {
    if (document.getElementById("ins_options").options
    [getElementById("ins_options").selectedIndex].value == "Individual") {
       document.getElementById("toggle").style.display = "none";
    } else {
       document.getElementById("toggle").style.display = "block";
    }
  }
</script> 
  • 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-09T06:33:25+00:00Added an answer on June 9, 2026 at 6:33 am

    You’re missing document in your selected index lookup – http://jsfiddle.net/VfEyW/

    So instead of

    [getElementById("ins_options").selectedIndex]
    

    try

    [document.getElementById("ins_options").selectedIndex]
    

    …

    UPDATE

    To check against 2 values you can do this

      function toggle() {
        var val = document.getElementById("ins_options").options[document.getElementById("ins_options").selectedIndex].value;
    
        if ( val == "Individual" || val == "Short Term" ) {
           document.getElementById("toggle").style.display = "none";
        } else {
           document.getElementById("toggle").style.display = "block";
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a select element that has a list of numbers
I am trying to create two select lists both filled with the same times.
I am trying to add a select box to the base of my create
I'm trying to create a select box drop down with a twist, Basically this
I'm trying to create a dropdown list with 'select' html tag , however ,
Im trying to create a select command to query the database I have and
I am trying to create a select list starting from the current date of
I have a DataGridView with a checkbox column. I'm trying to create a select/deselect
I'm new to this so bear with me. I'm trying to create a select
I'm trying to create a custom SELECT query to find my Personal Best races

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.