Jump to content

Recommended Posts

The first three fields were already there when i started but I wanted to add a fourth. I got this far but it's breaking on me still. It won't call up the last field. Doens't help that I don't know much about it...

 

<?php
// functions
function pullQuery($strMethod, $sqlSelect, $sqlDatatable, $sqlWhere, $sqlOrder, $output, $outputFieldOne, $outputFieldTwo, $outputFieldThree, $outputFieldFour) {
echo $query="$sqlSelect FROM ".DB_DATABASE.".$sqlDatatable $sqlWhere $sqlOrder";
$result=mysql_query($query);
while ($rs=mysql_fetch_object($result)) {
	if ($outputFieldOne) $newoutput=str_replace("#VALUE1#",$rs->$outputFieldOne,$output);
	if ($outputFieldTwo) $newoutput=str_replace("#VALUE2#",$rs->$outputFieldTwo,$newoutput);
	if ($outputFieldThree) $newoutput=str_replace("#VALUE3#",$rs->$outputFieldThree,$newoutput);
	if ($outputFieldFour) $newoutput=str_replace("#VALUE4#",$rs->$outputFieldFour,$newoutput);
	if ($strMethod=="echo") echo $newoutput;
	if ($strMethod=="return") return $newoutput;
}
mysql_query($query);
}
//

if ($_GET['province']) {
echo "<select name=\"consultantcity\" onChange=\"ajaxCall('call-data-shops.php?city='+this.value+'','location');\">";
echo "<option value=\"\" selected=\"selected\">- City -</option>";
pullQuery("echo", "SELECT DISTINCT city", "shopData", "WHERE province='".$_GET['province']."' AND shopType='Retail' AND status='Open'", "ORDER BY city ASC", "<option value=\"#VALUE1#\">#VALUE1#</option>\n", "city", "", "");
echo "</select>";
}
if ($_GET['city']) {
echo "<select name=\"consultantShop\ onChange=\"ajaxCall('call-data-shops.php?city='+this.value+'','consultant');\">";
echo "<option value=\"\" selected=\"selected\">- Location -</option>";
pullQuery("echo", "SELECT *", "shopData", "WHERE city='".$_GET['city']."' AND shopType='Retail' AND status='Open'", "ORDER BY shopName ASC", "<option value=\"#VALUE1#\">#VALUE1#</option>\n", "shopName", "", "");
echo "</select>";
}
if ($_GET['location']) {
echo "<select name=\"consultantName\  onChange=\"ajaxCall('call-data-shops.php?city='+this.value+'','consultant');\">";
echo "<option value=\"\" selected=\"selected\">- Consultant -</option>";
pullQuery("echo", "SELECT *", "shopStaffDetails", "WHERE firstName='".$_GET['firstName']."' AND lastName='".$_GET['lastName']."' AND shopName='consultantShop' AND status='Open'", "ORDER BY firstName ASC", "<option value=\"#VALUE1#\">#VALUE1#</option>\n", "consultantName", "", "");
echo "</select>";
}
?>

 

and the section of the form:

 

<table width="100%" border="0">
<tr>
	<td width="49%" align="right" valign="top"><span class="red">*</span> Please select the location that is the most convenient  for you: </td>
	<td width="51%" valign="top"><div style="float:left">
	<select name="province" id="province" onChange="ajaxCall('call-data-shops.php?province='+this.value+'','consultantcity')">
	<option value="" selected="selected">- Province -</option>
	<option value="Alberta">Alberta</option>
	<option value="British Columbia">British Columbia</option>
	<option value="Nova Scotia">Nova Scotia</option>

	<option value="Ontario">Ontario</option>
	</select>
	<div id="consultantcity" style="padding:5px 0 5px 0">
	<select name="consultantcity">
	<option value="" selected="selected"  disabled="disabled">- City -</option>
	</select>
	</div>
	<div id="location" style="padding:5px 0 5px 0">
	<select name="consultantShop" id="consultantShop">
	<option value="" selected="selected" disabled="disabled">- Location -</option>
	</select>
	</div>
	<div id="consultant" style="padding:5px 0 5px 0">
	<select name="consultantName" id="consultantName">
	<option value="" selected="selected" disabled="disabled">- Consultant -</option>
	</select>
	</div>
	</div></td>
</tr>
<tr>
	<td> </td>
	<td> </td>
</tr>
</table>

 

Any help would be greatly appreciated.

Cheers

 

Link to comment
https://forums.phpfreaks.com/topic/209142-ajax-wont-populate-fourth-field/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.