Hullo!
I have a set of dependent dropdown boxes and a very confusing anomaly with my dropdown data. I have a [I]client[I]projects
Client dropdown and subsequent div to load the dependent:
[code=php]
<select name=”category” onChange=”CategoryGrab(‘ajaxcalling.php?idCat=’+this.value);” class=”validate[required]”> <option>—</option>
<?
require “connect.php”;// connection to database
$q=mysql_query(“SELECT company FROM clients”);
while($n=mysql_fetch_array($q)){
echo “<option value='{$n[‘company’]}’>{$n[‘company’]}</option>”;
}
?>
</select>
<div style=”height:30px;” id=”details”></div>
Ajax Request is made to ajaxcalling.php (select is populated to container div using innerHTML):
[code=php]
<?
include(“connect.php”);
$ID=$_REQUEST[‘idCat’];
echo ‘<select name=”details” width=”100″>’;
$result = mysql_query(“SELECT * FROM projects WHERE client=’$ID'”);
while($row = mysql_fetch_array($result))
{
echo “<option value=”.$row[‘name’].”>”.$row[‘name’].”</option>”;
}
echo ‘</select>’;
mysql_close();
?>
Form action contains:
[code=php]
$project = $_POST[‘details’];
$client = $_POST[‘category’];
I don’t get it, client and project dropdowns both populate correctly, both have identical processing, yet the project gets cut off at the first whitespace. Any ideas?
Thanks a ton!
Nick