PDA

View Full Version : Help with jump menu


Paul Ferrie
10-23-2005, 10:57 AM
Hi guys,

I have a 20+articles on my clients website:

http://www.scotlet.co.uk/jcb/index.html

Iv'e been told that i have to do away with the frames. Each page is to hold it's own navigation to the other pages.

As well as there being the 20+ static pages on the server i also have a backup database of all these articles as well. I thought i would use the database side to create a jump menu to nav between the pages rather than hand coding each page, plus there comes the problem when pages are added or deleted.

Here is what i have so far.



<script type="text/JavaScript">

<!--

function MM_jumpMenu(targ,selObj,restore){ //v3.0

eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");

if (restore) selObj.selectedIndex=0;

}

//-->

</script>

<form id="form1" name="form1" method="get" action="">

<?php

$result = mysql_query("select arTitle from scArticles");

if ($result)

{

echo "<SELECT NAME='arTitle' onchange=\"MM_jumpMenu('parent',this,0)\">";

while ($myrow = mysql_fetch_array($result))

{

echo "<OPTION VALUE=\"".$myrow["arTitle"].".htm\">" . $myrow["arTitle"]." </OPTION> ";

}

echo "</SELECT>";

}

?>

</form>


It works so far.

The problem that i am having is when the selected page loads. How do i set the menu to display the current page being viewed.

I know where i need to put the code, just dont know what to put.



if(!empty($_POST['arTitle'])){

echo "<SELECT NAME='arTitle' onchange=\"MM_jumpMenu('parent',this,0)\">";

}else{

"<SELECT NAME='current page' onchange=\"MM_jumpMenu('parent',this,0)\">";

}

Any help very much appreciated.

Thanks

Paul