Want to give my thanks to web3schools for the example code
http://www.w3schools.com/php/php_ajax_database.asp
Dormilich tried to make sense on what you put up and then look around again. Seems like the option everyone recommended was ajax. This is what I have so far:
In the head of my code I have the following
The current page being view is blank_risk_form.php. i would like to stay on one page if possible
-
<SCRIPT language="javascript" type='text/javascript'>
-
-
-
//==================================COMBO AUTO GENERATE=====================================
-
function showUser(str)
-
{
-
if (str=="")
-
{
-
-
document.getElementById("txtHint").innerHTML="";
-
return;
-
}
-
if (window.XMLHttpRequest)
-
{// code for IE7+, Firefox, Chrome, Opera, Safari
-
xmlhttp=new XMLHttpRequest();
-
}
-
else
-
{// code for IE6, IE5
-
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
xmlhttp.onreadystatechange=function()
-
{
-
if (xmlhttp.readyState==4 && xmlhttp.status==200)
-
{
-
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
-
}
-
}
-
xmlhttp.open("GET","blank_risk_form.php?dep_code="+str,true);
-
xmlhttp.send();
-
}
-
-
</SCRIPT>
-
-
in the main body I have the following:
I set the value to negative one in order to keep the drop down empty. Don't know if thats even necessary but it just seemed right.
For the html part I did the following
-
<FORM NAME="blank_risk_form" id="blank_risk_form" method="post" action="submitnewrisk.php" onsubmit="return validate_form(this)">
-
-
Please note that the form is used for the rest of the page with other variables. I am showing this form in the case that someone says that I need a form.
This is the first drop down that returns the value that query's the second drop down and calls the javascript function. Here is where I don't see it working and where I need help
-
<th scope="col"><select name="cbo_subtsk" id="select" onchange="showUser(this.value)">
-
<?php
-
//BUILD DROP DOWN LIST
-
-
//FOR STATEMENT 1 START
-
echo '<option value=""></option>';
-
for ($array_1index=0; $array_1index < $dep_num; $array_1index += 1)
-
{
-
-
echo '<option value=';
-
echo $dep_array_code[$array_1index];
-
echo '>';
-
echo $dep_array_des[$array_1index];
-
echo '</option>';
-
-
}//FOR STATEMENT 1 END
-
-
?>
-
</select></th>
-
-
The second drop down should populate in theory based on the one above which is where I am having problems
-
-
<th scope="col"><span class="style4">
-
<select name="cbo_owner" id="select9" >
-
<?php
-
//BUILD DROP DOWN LIST
-
-
//FOR STATEMENT 1 START
-
echo '<option value=""></option>';
-
for ($array_1index=0; $array_1index < $user_num; $array_1index += 1)
-
{
-
-
echo '<option value=';
-
echo $user_array_id[$array_1index];
-
echo '>';
-
echo $user_array_last[$array_1index];
-
echo ", ";
-
echo $user_array_first[$array_1index];
-
echo '</option>';
-
-
}//FOR STATEMENT 1 END
-
-
?>
-
</select>
-
</span></th>
-
-
At this point the only thing I can say is that I am not sure why its not working. Any assistance on how to trouble shoot it would be greatly appreciated it