Hi,
Trying to populate a select statement with a jquery ajax call. The span element is populated if it outside of the form. When I copy and past the span element within the select statement, it doesn't produce the options. I can't figure out what I"m doing wrong. Would appreciate your help.
This works:
Code:
<html>
<head><title>This Title</title>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$.post("getpage.php",function(data){
$('#pagechoice').html(data);
});
});
</script>
</head>
<body>
<h1>Subject is Page Choice</h1>
<form name="page_select" id="pageselect" method="post" action="showpage.php">
<select name="page" size="1" style="width: 30em">
</select>
</form>
<span id="pagechoice"></span>
</body>
</html>
This doesn't work. The span has been moved up into the select statement:
Code:
<html>
<head><title>This Title</title>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$.post("getpage.php",function(data){
$('#pagechoice').html(data);
});
});
</script>
</head>
<body>
<h1>Subject is Page Choice</h1>
<form name="page_select" id="pageselect" method="post" action="showpage.php">
<select name="page" size="1" style="width: 30em">
<span id="pagechoice"></span>
</select>
</form>
</body>
</html>
This is the process page:
Code:
<?php
include("conandy.php");
error_reporting(E_ALL);
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
$rs = mysql_select_db("andy",$conn);
$sql = "SELECT * FROM page LIMIT 250";
if(!$sql){echo "Unable to select" . mysql_error();}
$rs = mysql_query($sql,$conn);
while($row=mysql_fetch_array($rs)){
echo("<option>" . $row['title'] . "</option>");
}
mysql_free_result($rs);
mysql_close($conn);
?>
Thank you,
Andy