Hi all,
I have the following. When i rollover an image link it displaying the sub menus for that link underneath. This all works fine but now i want to generate it dynamically.
This is the javascript:
<script language="JavaScript1.2">
var submenu=new Array()
//Set submenu contents. Expand as needed. For each content, make sure everything exists on ONE LINE. Otherwise, there will be JS errors.
submenu[0]='<font size="1" face="Verdana"><b><a href="#">E-Commerce Overview</a> | <a href="#">Small Business</a> | <a href="#">Large Corporations</a> | <a href="#">Take A Tour</a> | <a href="#">FAQ’s</a> | <a href="#">Pricing</a></b></font>'
submenu[1]='<font size="1" face="Verdana"><b><a href="#">Shopping Cart Features Overview</a> | <a href="#">Shopping Cart Feature Details</a> | <a href="#">Coming Soon</a></b></font>'
submenu[2]='<font size="1" face="Verdana"><b><a href="#">Testimonials</a> | <a href="#">Featured Users</a> | <a href="#">Case Studies</a></b></font>'
submenu[3]='<font size="1" face="Verdana"><b><a href="#">Contact Us</a> | <a href="#">Directory</a> | <a href="#">Support Materials</a></b></font>'
submenu[4]='<font size="1" face="Verdana"><b><a href="#">Partners</a> | <a href="#">News</a></b></font>'
submenu[5]='<font size="1" face="Verdana"><b><a href="#">Getting Started</a> | <a href="#">Request More Information</a> | <a href="#">Sign Up</a></b></font>'
submenu[6]='<font size="1" face="Verdana"><b><a href="#">Other Services Overview</a> | <a href="designguru/">designGURU</a> | <a href="../mailguru/">mailGURU</a> | <a href="../hostingguru/">hostingGURU</a> | <a href="../myguru/">myGURU</a></b></font>'
//Set delay before submenu disappears after mouse moves out of it (in milliseconds)
var delay_hide=500
/////No need to edit beyond here
var menuobj=document.getElementById? document.getElementById("describe") : document.all? document.all.describe : document.layers? document.dep1.document.dep2 : ""
function showit(which){
clear_delayhide()
thecontent=(which==-1)? "" : submenu[which]
if (document.getElementById||document.all)
menuobj.innerHTML=thecontent
else if (document.layers){
menuobj.document.write(thecontent)
menuobj.document.close()
}
}
function resetit(e){
if (document.all&&!menuobj.contains(e.toElement))
delayhide=setTimeout("showit(-1)",delay_hide)
else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhide=setTimeout("showit(-1)",delay_hide)
}
function clear_delayhide(){
if (window.delayhide)
clearTimeout(delayhide)
}
function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}
</script>
If i have the following query:
<?
include("include/dbconnect.php");
$sql_query = mysql_query("select * from category where category_parent = '3' and category_status = 'yes'");
while($row = mysql_fetch_array($sql_query)){
$category_id = $row["category_id"];
$category_name = stripslashes($row["category_name"]);
echo "$category_name | ";
}
?>
how do i modify the javascript to echo the results, in this example i want to get the above query to be in place of the javascript line submenu[0]....this is what i tried:
submenu[0]='<font size="1" face="Verdana"><b><a href="#"><? echo $category_nam ?></a> | </b></font>'
Cheers,
micmac