EDIT 1
I am getting courseID from this code:
$coursesOutput = '<option value=""></option>';
while($row = mysql_fetch_array($result2)){
$courseID = $row['courseID'];
$courseName = $row['name'];
$coursesOutput .= '<option value="' . $courseID . '">' . $courseName . '</option>';
}
My php script is as follows (returning an echo statement)
<?php
include ("includes/connect.php");
$courseID = mysql_real_escape_string($_GET['courseID']);
$sql = "SELECT tee1, tee2, tee3, tee4, tee5 FROM courses WHERE courseID='$courseID' LIMIT 1";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$tee1 = $row['tee1'];
$tee2 = $row['tee2'];
$tee3 = $row['tee3'];
$tee4 = $row['tee4'];
$tee5 = $row['tee5'];
}
$teesOutput = '<option value="' . $tee1 . '">' . $tee1 . '</option>';
if($tee2 != ""){
$teesOutput .= '<option value="' . $tee2 . '">' . $tee2 . '</option>';
}
if($tee3 != ""){
$teesOutput .= '<option value="' . $tee3 . '">' . $tee3 . '</option>';
}
if($tee4 != ""){
$teesOutput .= '<option value="' . $tee4 . '">' . $tee4 . '</option>';
}
if($tee5 != ""){
$teesOutput .= '<option value="' . $tee5 . '">' . $tee5 . '</option>';
}
echo '' . $teesOutput . '';
die();
?>
I am not getting any ajax errors but still nothing populating in my tee selector. Hope this helps, once again I am overwhelmed by the support here, unbelieveable!
End EDIT 1
I have been unable to figure this AJAX-JQUERY feature out for awhile now. It should be an easy spot for good jQuery programmers.
I want to be able to auto-populate my tee select input after a user selects their course. This is a golf app and courses have several different tee color schemes so each will be course specific.
So far my broken codes are:
HTML
<form id="formAddScore" action="addscore.php" enctype="multipart/form-data" method="post">
<p class="profile_label">Select Date:</p>
<input type="text" id="datepicker" name="datepicker" class="score_input" />
<p class="profile_label">Select Course:</p>
<select id="course" name="course" class="score_input" onchange="populateTee(this.value)">
' . $coursesOutput . '
</select>
<p class="profile_label">Select Tee:</p>
<select id="tee" name="tee" class="score_input">
</select>
<p class="profile_label">Actual Score:</p>
<input id="score" name="score" class="score_input" type="text" size="10" />
<p class="profile_label">Score ESC (Equitable Stroke Control):</p>
<input id="scoreESC" name="scoreESC" class="score_input" type="text" size="10" />
<br/>
<input id="btnAddScore" name="btnAddScore" class="btn_score" type="submit" value="Add Score" />
</form>
JQUERY
function populateTee(courseID)
{
$.ajax(
{
url: 'includes/populate_tee.php?courseID=' + courseID,
success: function(data) {
$("#tee").html(data);
}
});
}
PHP
populate_tee.php script WORKS, so I won't waste your time including it.
I am fairly certain the problem is in the above JQUERY-AJAX script.
Any help would be wonderful.
Thanks in advance.
Where does courseID come from? Try logging it into the console. Does this help?
Instead of using onChange event on select i suggest use of jquery .change() method. Try following code it should solve the problem.