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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:36:51+00:00 2026-05-22T01:36:51+00:00

For my code, my drop down lists are initiated on the original page, via

  • 0

For my code, my drop down lists are initiated on the original page, via

<select name =country id=country 
onchange=showRecords(this.value,'country','province')>"

This function is taking the value, equating it to country, then querying MySQL, and setting the results where id=province, and creating cascading dropdown lists. This is obviously via Ajax.

So, when $_REQUEST[‘province’] is set, then the Province dropdown list gets populated with all provinces from the country to which it belongs, etc.; i.e.;

<?if(isset($province)){
echo "<script>showRecords('".$country."','country','province');</script>";}?>

However, for the life of me, I cannot figure out how I can set the default value equal to $_REQUEST[‘province’]. I cannot use the traditional way:

if (($selected) == ($value)) {
 $options.= " selected";
 }

Because it is querying the AJAX page with one piece of information at a time.

Any ideas would be 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-22T01:36:52+00:00Added an answer on May 22, 2026 at 1:36 am

    I have a lot of assumptions to your questions,

    first is, if bydefault you have the select province like this

    <select id="province">
     <option value=""></option>
     <option value="California">California</option>
     <option value="Washington">Washingthon</option>
    </select>
    

    then you can use this script to default select

    document.getElementById("province").value="Washington"; 
    

    but if bydefault you have the select province like this

    <select id="province"></select>
    

    then you can use this script to default select

    document.getElementById("province").innerHTML='<option value="Wahsington">Washington</option>'; 
    

    so it depend on your code and your need. maybe if you have another case the problem should be solved in another way.

    cmmiiw 🙂

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

Sidebar

Related Questions

I have the following code that populates two drop down lists, it all works
I'm creating a data capturing page with drop down lists that are dynamically filled
I've got a page which will have about ten drop down lists which are
i created four drop down select lists in html and dynamically load them from
On top of visual studio code editor, There are two drop down lists displays
I have two drop down lists. Second one is populated based on value chosen
I have two drop down lists on a page. The behavior is as follows:
I have JSF page has two drop down lists and I want to load
I have a View Feedback page with two drop down lists to filter the
I have a page that has two drop down lists on it and a

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.