I have searched various forums for this seemingly "basic" function with no avail. I posted in a javascript forum and it was suggested that I try AJAX for my solution.
Here is my scenario. I have a drop down menu listing a number of locations (101 to be exact). When a customer selects their location, the response needs to pull the information linked to that location from a mySQL database and auto-fill 6 text fields.
this is the javascript code I have so far.
The call to the function is coming from a dynamic drop down menu. The code is here:
This equates to a 101 line menu when viewed in source code from the browser.
I am looking for someone to point me in the right direction.
Thanks in advance
Thanks,
Lester
Here is my scenario. I have a drop down menu listing a number of locations (101 to be exact). When a customer selects their location, the response needs to pull the information linked to that location from a mySQL database and auto-fill 6 text fields.
this is the javascript code I have so far.
Code:
function selectCompany(selObj) {
var id=<?PHP echo $row_franchise['id']; ?>;
var companyArray = new Array();
companyArray.id=new Array();
companyArray.id.company=<?PHP echo $row_franchise['company']; ?>;
companyArray.id.address=<?PHP echo $row_franchise['address']; ?>;
companyArray.id.city=<?PHP echo $row_franchise['city']; ?>;
companyArray.id.state=<?PHP echo $row_franchise['state']; ?>;
companyArray.id.zip=<?PHP echo $row_franchises['zip']; ?>;
companyArray.id.phone=<?PHP echo $row_franchise['phone']; ?>;
document.getElementById('company').value = companyArray[id][0];
document.getElementById('address').value = companyArray[id][1];
document.getElementById('city').value = companyArray[id][2];
document.getElementById('state').value = companyArray[id][3];
document.getElementById('zip').value = companyArray[id][4];
document.getElementById('telephone').value = companyArray[id][5];
}
The call to the function is coming from a dynamic drop down menu. The code is here:
Code:
<select name="franchise" id="franchise" onchange="selectCompany(this)">
<?php
do {
?>
<option value="<?php echo $row_franchise['id']?>"<?php if (!(strcmp($row_franchise['id'], $row_franchise['id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_franchise['company']?></option>
<?php
} while ($row_franchise = mysql_fetch_assoc($Franchises));
$rows = mysql_num_rows($Franchises);
if($rows > 0) {
mysql_data_seek($Franchises, 0);
$row_franchise = mysql_fetch_assoc($Franchises);
}
?>
</select>
This equates to a 101 line menu when viewed in source code from the browser.
I am looking for someone to point me in the right direction.
Thanks in advance
Thanks,
Lester