Hi All, i'm new to this board. I'm having a spot of bother with the following: Here is what i'm trying to do.
From the drop down list (generated from my database) a style is selected and the image is displayed in the preview box next to it.
The problem I am having is that the onchange event that i'm using is not working. is there any way of doing this without using javascript? or is there a way of doing it with both javascript and PHP together? I know the Javascript is client side and PHP is server side. I've been trying this for ages now without success. Any help would be apprciated.
here is the code:
From the Head Section of the page:
<script language="javascript" src="cgi-bin/go.js" type="text/javascript"></script>
<script language="javascript" src="cgi-bin/showimage.js" type="text/javascript"></script>
<script language="javascript" src="cgi-bin/Paypal.js" type="text/javascript"></script>
<script language="javascript" src="cgi-bin/checkboxclick.js" type="text/javascript"></script>
(showimage.js):
function showimage()
{
if (!document.images)
return
document.images.pictures.src=
document.forms.os0.options[document.mygallery.os0.selectedIndex].value2
}
My PHP code:
<?
$username="***********";
$password="***********";
$database="********";
mysql_connect("**********",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT style_name,img_url FROM product WHERE product_name = 'Day You Were Born' order by style_name";
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
$result = mysql_query ($query);
print "<select name=\"os0\" onchange=\"showimage()\">";
// printing the list box select command
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
print "<option value=\"$nt[style_name]\" value2=\"$nt[img_url]\">$nt[style_name]</option>";
/* Option values are added by looping through the array */
}
print "</select>";// Closing of list box
?>
the full page can be seen here: http://www.personally-yours.co.uk/development/onthisdaydev.php
any help would be appreciated. Cheers!!!!!!