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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:09:46+00:00 2026-05-16T20:09:46+00:00

I am working on dynamic form. i have a radio button, if a user

  • 0

I am working on dynamic form.
i have a radio button, if a user select a radio button, i want to populate a drop down menu based on the radio button values.

eg. if radio button value=value1 show drop menu of 3 items (apple, banana, mango)

eg. if radio button value=value2 show drop menu of 5 items (apple, banana, mango,apricot, ornage)

etc. I have used css to hide and show the drop down menu.

(1) the problem i am having is, this doesn’t work when i insert my form in a <table></table>; when i remove the table tags it works. its a bit strange…

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
<!--

function changeDiv(the_div,the_change)
{
  var the_style = getStyleObject(the_div);
  if (the_style != false)
  {
    the_style.display = the_change;
  }
}

function hideAll()
{
  changeDiv("main_category","none");
  changeDiv("another_category","none");
  changeDiv("other_category","none");
}

function getStyleObject(objectId) {
  if (document.getElementById && document.getElementById(objectId)) {
    return document.getElementById(objectId).style;
  } else if (document.all && document.all(objectId)) {
    return document.all(objectId).style;
  } else {
    return false;
  }
}
// -->
</script>
</head>

<body>
<table>

<tr>
  <td align="right" valign="top">Main Category:</td>
  <td>
  <input type="radio" name="main_cat" onClick="hideAll(); changeDiv('main_category','block');" value="value1">value1<br />
  <input type="radio" name="main_cat" onClick="hideAll(); changeDiv('main_category','block');" value="value2">value2<br />
  <input type="radio" name="main_cat" onClick="hideAll(); changeDiv('main_category','block');" value="value3">value3<br />
  <input type="radio" name="main_cat" onClick="hideAll(); changeDiv('main_category','block');" value="value4">value4
  </td>
</tr>


<div id="main_category" style="margin-left:30px;display:none">
<tr>
  <td align="right">Options:</td>
  <td></td>
</tr>
</div>

<tr>
  <td align="right">Aanother Category:</td>
  <td>
  <input type="radio" name="another_cat" onClick="hideAll(); changeDiv('another_category','block');" value="Yes">Yes
  <input type="radio" name="another_cat" value="No">No
  </td>
</tr>


<div id="another_category" style="margin-left:30px;display:none;">
<tr>
  <td align="right">Other Category:</td>
  <td>

  </td>
</tr>

<tr>
  <td align="right">Interest:</td>
  <td>

  </td>
</tr>
</div>





</table>
</body>
</html>

(2) second question is, i have a second radio buttons like this:
eg. if radio button value=value1 show drop menu of 3 items (apple, banana, mango)
eg. if radio button value=value2 show drop menu of 5 items (apple, banana, mango,apricot, ornage) etc. I have used css to hide and show the drop down menu.

now the trick is, if i already selected value=value1, i don’t want to show value1 again in the second radio button

any help/suggestions is greatly appreciated.

  • 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-16T20:09:46+00:00Added an answer on May 16, 2026 at 8:09 pm

    try this

    <html>
        <head>
            <script type="text/javascript">
                         var comList= new Array("apple","banana","mango");
                         var list = new Array("orage", "apricot");
                         var val1selected = 0;  
    
                 function loadDropDown(option){
                             setSelectdVal(option)
                             createDropDown(option)
                         }  
                     function setSelectdVal(option){
                             if (option == 1){
                               val1selected = 1; 
                             } 
                         }       
    
                         function createDropDown(option){
                            html = "";
                            html = html + '<select id="id">'
                            var arr = getArray(option);
                            for (var i=arr.length-1; i>=0; --i ){
                                html = html + '<option value="' + i + '">' + arr[i] + '</option>' 
                            }
                            html = html + '</select>'
                            document.getElementById('selectTag').innerHTML = html;
                 }
                         function getArray(option){
                            var a = comList;
                            if ((option == 2) && (val1selected == 0)){
                               a = comList.concat(list)
                            }
                            return a;
                         }
    
                    </script>
        </head>
            <body>
            <table>
                        <tr>
                            <td><input type="radio" name="options" onClick=loadDropDown(1);>value1</td>
                            <td><input type="radio" name="options" onClick=loadDropDown(2);>value2</td>
                        </tr>
                <tr>
                            <td></td>
                            <td id="selectTag"></td>
                        </tr>   
                    </table>
            </body> 
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a dynamic menu system as the site I'm build has
today I've been working on loading dynamic javascript code (files). The solution I use
Our workflow currently has developers working on locally hosted copies of our web application
I am creating a dynamic table control with ASP.NET/C# and the table is being
Hi this question or problem i have its very hard i have search and
I am trying to bind a data class to a ListView control in WPF,
Ok, I hope this will be my last question in a series of Q's
I am trying to write some kind of raw html to mimic what spring
I'm using a wizard control, step 1 has a list box with a list

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.