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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:20:55+00:00 2026-06-11T15:20:55+00:00

I have five dropdown list which depending on the selection the display changes to

  • 0

I have five dropdown list which depending on the selection the display changes to block.
The problem comes when values are posted back. The drop down list does not show the values. This likely because of javascript that by default displays as none the drop down list. The javascript listens for onclick. Here is part of the javascripts:

 function changeOptions() {
    var form = window.document.getElementById("frm1");
    var sv = window.document.getElementById("sv");
    var sv2= window.document.getElementById("sv2");
var sv3 = window.document.getElementById("sv3");
    var sv4= window.document.getElementById("sv4");
var sv5 = window.document.getElementById("sv5");


if (form.radioButton1.checked) {
        sv2.style.display = "none";
sv3.style.display = "none";
sv4.style.display = "none";
sv5.style.display = "none";
        sv.style.display = "block";
        //sv.selectedIndex =0;

  else if (form.radioButton5.checked) {
        sv.style.display = "none";
        sv2.style.display = "none";
        sv3.style.display = "none";
        sv4.style.display = "none";
        sv5.style.display = "block";
        sv5.selectedIndex = 0;
    }

}
window.document.getElementById("radioButton5").onclick = changeOptions;

The dropdown menu is populated from my database. Below is the code. There are five of them The display:none changes to block depending which radio button is clicked.

   <select style="width:200px; **display:none**" name="pGroup" id="sv" >

<option value="Choose an Option" >Choose Product Group</option>
<?php
$selGroup = isset($_GET['pGroup'])?$_GET['pGroup']:"";
$sql="SELECT DISTINCT pGroup FROM cr39 WHERE ";
$sql.="HeadingNo = 3 ORDER BY pGroup ASC";
$result =mysql_query($sql);
while ($data=mysql_fetch_assoc($result)){
?>

<option <?php if($data['pGroup'] == $selGroup) echo 'selected="selected"'; ?> value ="<?php echo $data['pGroup'] ?>" ><?php echo $data['pGroup'] ?></option>
<?php } ?>

</select>

.
.
.
.

    <select style="width:200px; **display:none**" name="pGroup5" id="sv5">

<option value="Choose an Option" >Choose Product Group</option>
<?php 
$selGroup = isset($_GET['pGroup5'])?$_GET['pGroup5']:"";
$sql="SELECT DISTINCT pGroup FROM cr39 WHERE ";
$sql.="HeadingNo = 7 ORDER BY pGroup ASC";
$result =mysql_query($sql);
while ($data=mysql_fetch_assoc($result)){
?>

<option <?php if($data['pGroup'] == $selGroup) echo 'selected="selected"'; ?> value ="<?php echo $data['pGroup'] ?>" ><?php echo $data['pGroup'] ?></option>
<?php } ?>

</select>

I am a novice in this and would like help on how to retain the value on my dropdownon postback.

  • 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-11T15:20:57+00:00Added an answer on June 11, 2026 at 3:20 pm

    per comment above, would need to see more code to be exact, but here is a pseudo version that you may be able to adapt;

    <body 
    <?PHP if(isset($_GET['selectedGroupId'];)){ ?>
        onload='window.document.getElementById("radioButton<?PHP echo $_GET['selectedGroupId']; ?>").click()'
    <?PHP } ?>
    >
    

    replace $_GET['selectedGroupId'] with your fieldname/id

    see if that gets you on the right track

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

Sidebar

Related Questions

In my XSL i have included a dropdown box which have values like, one
I have five lists List<String> . I want to get a single array which
I have five values, A, B, C, D and E. Given the constraint A
I'm working on a horizontal gallery that will display mixtape covers, I have five
I have five strong-typed List objects. Every object inside every List have property Rating
In my case I have five huge text files,which I have to embedd into
We have a number of list items in an unordered list of which we
I have web page in which i want to slide the images problem is
I have five buttons on one form that when clicked enables a bool each
I have five divs on my page (#art #fashion, #self, #nightlife, #community). right now,

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.