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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:04:50+00:00 2026-06-11T07:04:50+00:00

Hi I have this code that will pull the client name and address from

  • 0

Hi I have this code that will pull the client name and address from the database.
It echo’s out the client name for each entry into a dropdown (<option value="<?php echo "$client" ?>"><?php echo "$client" ?></option>) which is done in a while loop.
Then i have a Javascript that will change the innerHTML of a DIV named ‘content’ when you select a option in the dropdown – this is unique based on what is pulled from the database. – This is where I can’t get it to work.. below is my code any help is much appreciated.

<div id="selectBox">
<div class="ui-widget">
<form>
    <label>Select a Client:</label>
    <select id="combobox" >
    <option value="">Select...</option>
    <?php

include "db_conn.php";

callDB();   

function callDB(){      
$sql = 'SELECT * FROM clientlist';
   $query = mysql_query($sql) or die(mysql_error());
   while ($row = mysql_fetch_array($query))
          {
       $ID= $row['id'];
       $client= $row["client"];
       $postal_add= $row["postal_add"];
?>

<option value="<?php echo "$client" ?>"><?php echo "$client" ?></option>
        <?php
}} ?>
    </select>
    </form>
</div>
</div>
<br>
<div id="content">

</div>
</div>
<script type="text/javascript">



// Script for changing Div
function change()
{
switch (document.getElementById("combobox").value)
{
  case "<?php echo $client ?>":
  document.getElementById("content").innerHTML = "<h2><?php echo $client ?></h2><b>Postal Address:</b> <?php echo $postal_add ?>"
  break;

}
}

</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-11T07:04:52+00:00Added an answer on June 11, 2026 at 7:04 am

    By the time the Javascript is executed (Client), PHP already finished (Server). You will need to build the Javascript from PHP inside the While-Loop and send it to the browser later in the page:

    // in while
    $javascript .= "case $client:
    document.getElementById('content').innerHTML = '<h2>$client</h2>
        <b>Postal Address:</b>$postal_add'
    break;"
    
    // later in page
    switch (document.getElementById("combobox").value)
    {    
    <?php echo $javascript; ?>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this code that will check the array contains the specific string and
I have this code that will check for if the class more-results are in
I have the this code that will create excel file and work sheet then
I have this code: <script id=toModify > Invalid javascript that will cause errors </script>
I have this code that reads from XML file. It gets five strings (groupId,
I've created a dynamic table that will pull information from a database. However, there
I have a website that grabs a random entry from a database and displays
I have this code that I've edited: http://pastebin.com/vrqHek6S I've put in comments where I
I have this code that runs but never stops. class A { public static
I have this code that suppose to place the marker by the latlng public

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.