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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:09:32+00:00 2026-05-25T06:09:32+00:00

Disclaimer: It’s been a while since I last wrote any code. The quality of

  • 0

Disclaimer: It’s been a while since I last wrote any code. The quality of my code is likely to be sub-par. You’ve been warned.

Greetings.

I am coding a basic form that uses a SELECT list I populate from my database.

However, my user needs the form to be dynamic and wants to be able to select either MasterTable1 or MasterTable2 or MasterTable3…

Instead of hardcoding the table name for the database query that populates the SELECT list, I attempted to implement a basic Ajax action (used example from w3schools)…and that’s when I lost my sanity…

I can output <div id='txtHint'></div> in my page and it shows the correct table name that was picked.

But how do I pass the correct table name to my query that will populate my SELECT list???

I tried

 <select name="DBFilename" id="DBFilename" size="0"> 
 <option value="">Select Filename</option> 
<?php 
$sql="select distinct filename from "."<div id='txtHint'></div>";
$result = mysql_query($sql);
 while ($row = mysql_fetch_array($result)){ ?>  
 <option value="<?php echo $row['filename']; ?>"><?php echo $row['filename']; ?></option> 
 <?php } ?> 
 </select> 

But to no avail. This is confusing since I can do this…

...
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","gettable.php?q="+str,true);
xmlhttp.send();
}
</script></head>
<body><form><select name="SrcTbl" id="SrcTbl" size="0" onchange="showTable(this.value)"> 
    <option value="">Select Data Table</option> 
    <option value=""> </option> 
<option value="MasterTable1">up to 31 days old</option> 
<option value="MasterTable2">62 days old</option> 
</select>
</form><br /><div id="txtHint"><select name="tabList"><option></option></select> </div>
</body></html>

And the name of my table will be displayed in the SELECT list ‘tablist’.

How do I pass the correct table name to my query that will populate my SELECT list? Thanks!!

(Pastebin =>form code)

  • 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-25T06:09:32+00:00Added an answer on May 25, 2026 at 6:09 am

    m8, ajax is mainly used for user experience and populating a select list is so easy mode that it shouldnt be bothered with ajax in the first place!

    You should use ajax if you want to use some methods on user submitted data and create an illusion of seamless data exchange between the server and the client, and based on the return results render a corresponding view or an element of the view.

    unless you load every element of the view with ajax, you should populate your html with php from the start!

    <select name="DBFilename" id="DBFilename" size="whatever since style belongs to css"> 
    <option selected="selected">Select Filename</option> 
    <?php 
    $sql="SELECT DISTINCT filename from 'wherever'";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)){ ?>  
    <option value="<?php echo $row['filename']; ?>"><?php echo $row['filename'];?>
    </option> 
    <?php } ?> 
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DISCLAIMER: The following code is not something I would ever use in a real
Disclaimer While this question looked like a potential duplicate , it was resolved by
Disclaimer: I am a layperson currently learning to program. Never been part of a
DISCLAIMER: While I'm trying to do this to fool a license enforcement scheme, the
Disclaimer: I know this type of question has been asked here before, I just
Disclaimer: I'm sure this has been answered before but I cannot find anything on
Disclaimer: This is not actually a programming question, but I feel the audience on
Disclaimer: I'm stuck on TFS and I hate it. My source control structure looks
Disclaimer: the following is a sin against XML. That's why I'm trying to change
Disclaimer: I'm fairly new to python! If I want all the lines of 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.