http://205.144.211.142/WEB/test.php
Thats the script in question, its using sajax to lookup albums based on the selected author, however the way it works, the album selection box doesn't appear till you select an artist, but creating the box before hand doesn't work.
Eg, this does not work.
PHP:
function requestalbum($artist)
{
$SQL = "SELECT DISTINCT ALBUM FROM ". DB_LIBRARY ." WHERE `ARTIST`='$artist' ORDER BY ARTIST ASC";
$QUERY = mysql_query($SQL);
while($ALBUM = mysql_fetch_array($QUERY)) {
$album_info .= "<option value={$ALBUM["ALBUM"]}>{$ALBUM["ALBUM"]}</option>";
}
return $album_info;
}
sajax_init();
sajax_export("album_show");
sajax_export("requestalbum");
sajax_handle_client_request();
JS:
function request_info()
{
x_requestalbum(document.getElementById("artistform").value, update);
}
function update(data)
{
document.getElementById("album").innerHTML = data;
}
HTML:
<select name="album" size=5 style="width:40%; margin:5px 0 5px 0;">
<div id="album"></div>
</select>
However, this does work lol, but its not quite the intended effect:
I add this as a variable in the php scripting:
function requestalbum($artist)
{
$SQL = "SELECT DISTINCT ALBUM FROM ". DB_LIBRARY ." WHERE `ARTIST`='$artist' ORDER BY ARTIST ASC";
$QUERY = mysql_query($SQL);
//set album_info to the select html box
$album_info = "<select name=\"album\" size=5 style=\"width:40%; margin:5px 0 5px 0;\">";
while($ALBUM = mysql_fetch_array($QUERY)) {
$album_info .= "<option value={$ALBUM["ALBUM"]}>{$ALBUM["ALBUM"]}</option>";
}
return $album_info;
}
The HTML then being this:
<div id="album"></div>
</select>
However I want the box to appear beforehand, but if I do the first method, none of the options show up.