Hi there,
I have a select box that fires this onChange event.
It calls this php page.
This works great when a user is adding a new quote/order as the customer contact details are populated by the code above.
What I am looking for is when a user is editing an existing quote/order. The php page displays the correct value for the CustomerContact but their details (phone/email etc) remain hidden until the onChange event fires.
Is there some way to get the Javascript routine to fire in the event of the select box already having another entry selected?
I have tried putting the code in the onLoad event of the pages body.
Any ideas would be appreciated.
Peter.
Remember- It's nice to be important,
but it's important to be nice
I have a select box that fires this onChange event.
Code:
var xmlhttp;
function showUser(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="getuser.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
It calls this php page.
Code:
<?php
$q=$_GET["q"];
$con = mysql_connect('localhost', 'root', 'xxxxxxxx');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("neworders", $con);
$sql="SELECT * FROM customercontacts WHERE CustomerContactID = '".$q."'";
$result = mysql_query($sql);
echo "<table style='width:100%'>";
$row = mysql_fetch_array($result);
echo "<tr><td style='width:50%'>Phone</td><td style='width:50%'><input type='text' name='ContactPhone' value='" . $row['ContactPhone'] . "'></td></tr>";
echo "<tr><td>Fax</td><td><input type='text' name='ContactFax' value='" . $row['ContactFax'] . "'></td></tr>";
echo "<tr><td>Email</td><td><input type='text' name='ContactEmail' value='" . $row['ContactEmail'] . "'></td></tr>";
echo "<tr><td>Mobile</td><td><input type='text' name='ContactMobile' value='" . $row['ContactMobile'] . "'></td>";
echo "</tr>";
echo "</table>";
mysql_close($con);
?>
This works great when a user is adding a new quote/order as the customer contact details are populated by the code above.
What I am looking for is when a user is editing an existing quote/order. The php page displays the correct value for the CustomerContact but their details (phone/email etc) remain hidden until the onChange event fires.
Is there some way to get the Javascript routine to fire in the event of the select box already having another entry selected?
I have tried putting the code in the onLoad event of the pages body.
Any ideas would be appreciated.
Peter.
Remember- It's nice to be important,
but it's important to be nice