Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fire event on Dynamic Select if exising record.

Status
Not open for further replies.

petrosky

Technical User
Aug 1, 2001
512
AU
Hi there,

I am still finding my way in the world of PHP. I recently found out about AJAX and am trying to use it on an order form.

A Customer can have many Contacts.

My dynamic select works like this.

Code:
<td><select name="CustomerContactID" onchange="showUser(this.value)">
		<option  value ="0">-Select Contact-</option>
<?php
// Build the SQL for the Contact Select
$sql = "Select CustomerContactID, ContactName FROM customercontacts WHERE CustomerID = ".$CustomerID." ORDER BY ContactName ASC";
	
// Run the query.
$results = conn($sql);

//Loop through the recordset.
while ($row = mysql_fetch_row($results)){

$selected = "";

if( $ContactName == $row[1]) {
    $selected = "selected";
}
$display .= '<option value="'.$row[0].'"'  . $selected . ">" . $row[1] . "</option>\n";

} // End while loop.
echo $display;	
?>
</select>

Th onchange event fires as expected and AJAX populates the customer contact's phone number etc.

What I would like to have happen is if the user is editing an existing record...the "showUser" routine will fire and fill in the existing extra details (phone/email etc)

Currently I have to manually select another option before this event fires.

Is there another event I can call to fire the function?

If this post is more appropriate in the Javascript forum, I apologise in advance.

Thanks for any ideas you may have.

Peter.

Remember- It's nice to be important,
but it's important to be nice :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top