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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:09:45+00:00 2026-05-26T04:09:45+00:00

I am trying to have 2 separate divs with one labeled Email and the

  • 0

I am trying to have 2 separate divs with one labeled Email and the 2nd div named Number. When a user chooses a person from drop down the retrieved info from PHP + MySQL should be added in a div just how it gets added to the div when you click add at: http://jsfiddle.net/QVUHU/84/

I am stuck because I dont know how to add the retrieved info into 2 divs one for email one for number like the one at js fiddle…

Below is my html + ajax and PHP code

HTML + AJAX

<html>
<head>
<script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML+=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>

<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="1">Achau</option>
<option value="2">Ravi</option>
<option value="3">Justin</option>
</select>
</form>
<br />


<div id="txtHint">
<b><table>
<tr>
<th>Email</th>
<th>Number</th>

</tr></b></div>



</body>
</html> 

PHP + MySQL

<?php
$q=$_GET["q"];

$con = mysql_connect("tghbdfg1","Userbhgins","Jpgbhfw3");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("UserLogins", $con);

$sql="SELECT * FROM PersonInfo WHERE id = '".$q."'";

$result = mysql_query($sql);

echo " <br />";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['Email'] . "</td>";
  echo "<td>" . $row['PNumber'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?> 
  • 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-26T04:09:46+00:00Added an answer on May 26, 2026 at 4:09 am

    HTML:

    <th>Email: <div id="email"></div></th>
    <th>Number: <div id="number"></div></th>
    

    JavaScript:

    document.getElementById["email"].innerHTML = "Hello";
    document.getElementById["number"].innerHTML = "World";
    

    EDIT:

    No need to return html tags in your respnse. There are better ways to do this(JSON response) but this is simplest solution:

    while($row = mysql_fetch_array($result))
      {
      echo $row['Email'] . "|" . $row['PNumber'];
      }
    

    Javascript:

    Replace

    document.getElementById("txtHint").innerHTML+=xmlhttp.responseText;
    

    With:

    var emailPhoneArray = xmlhttp.responseText.split("|");
    
    if(emailPhoneArray != null && emailPhoneArray.length() == 2) {
        document.getElementById["email"].innerHTML = emailPhoneArray[0];
        document.getElementById["number"].innerHTML = emailPhoneArray[1];
    }
    else {
        alert("Wrong response!");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to integrate CAS on Liferay. I have separate CAS server running
I'm trying to get crawl to work on two separate farms I have but
I am trying to have a table header, in a seperate div stay in
Am trying to have an image visually echo through from intro page to homepage~which
I am trying to add some multiple form fields in separate divs. But by
I have 2 divs, one needs to be a fixed width, the other responsive
I am trying to have one one layer, and center images within. I.E., if
I'm trying to accomplish a layout like the one below: Two float:left divs are
My roommate and I each have a separate webserver we are trying to set
I'm trying to build a basic application which will have 2 separate components which

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.