Hjælp til menu
Hej Eksperter.Jeg er igang med at lave en kalender, og der har jeg fundet en lille fin menu til, den gør sådan når jeg holder min mus over et billede, så kommer den med en lille dropdown menu, hvor jeg så kan vælge mellem 2 links.
Men da det er java og ligger på min index.php fil oppe i body, så har jeg et problem med at få angivet et id i det link i menuen man nu ønsker at benytte.
linket skulle evt. se sådan ud: redi.php?id=1
men i stedet ser det sådan ud: redi.php, og det medføre jo at jeg ikke kan komme ind og få fat i det rigtige id når jeg vil redigere en event.
koden på javaet:
<script type="text/javascript">
/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var defaultMenuWidth="150px" //set default menu width.
var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
linkset[0]='<a href="<? echo $dag; ?>">Rediger event</a>'
linkset[0]+='<a href="#">Slet event</a>'
////No need to edit beyond here
var ie5=document.all && !window.opera
var ns6=document.getElementById
if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')
function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}
function showmenu(e, which, optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=which
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}
function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}
function hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}
function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}
function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}
function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}
if (ie5||ns6)
document.onclick=hidemenu
</script>
og min php kode længere nede på siden:
<?php
require "db.php";
$query = mysql_query ("SELECT * FROM priv_kal WHERE vigtig='1' ORDER BY dag ASC");
if (mysql_num_rows($query)==0) {
echo"<br /><table width=\"340\" border=\"1\" bordercolor=\"#000000\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
<tr><td width=\"340\">
<table width=\"340\" cellpadding=\"0\" cellspacing=\"0\">
<td width=\"10\" valign=\"middle\" bgcolor=\"#E3E3E3\" class=\"god_txt\"><img src=\"adm/images/warning.gif\" width=\"23\" height=\"25\"></td>
<td width=\"330\" valign=\"middle\" bgcolor=\"#E3E3E3\" class=\"god_txt\"> Der er ingen nyheder.</td>
</table>
</td>
</tr>
</table><br>";
}
while ($row = mysql_fetch_array($query)) {
$oversk = nl2br($row['oversk']);
$tekst = $row['tekst'];
$id = $row['id'];
//Hent dato, ændre dato til tekst.
$dag = $row['dag'];
$date = date_parse($dag);
$dag_y = $date["year"];
$dag_m = $date["month"];
$dag_d = $date["day"];
$dag_m_get = $dag_m;
$dag_m_word = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");
$dag_m_rep = array("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec");
$dag_m_done = str_replace($dag_m_word, $dag_m_rep, $dag_m_get);
//Hent begivenheds tekst
$begiven_get = $row['begiven'];
$begiven_word = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15");
$begiven_rep = array("Fødselsdag", "Møde", "Køretur", "Ferie", "Læge", "Frokostaftale", "Projekt", "Vigtigt", "Sjovt", "Børnepasning", "God ting", "Telefonsamtale", "Regning", "Løn", "Studere");
$begiven_word_done = str_replace($begiven_word, $begiven_rep, $begiven_get);
//Hent begivenheds billede
$begiven_get = $row['begiven'];
$begiven_pic_word = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15");
$begiven_pic_rep = array("foedsdage.jpg", "moede.jpg", "bil.jpg", "ferie.jpg", "doktor.jpg", "frokost.jpg", "projekt.jpg", "vigtigt.jpg", "sjov.jpg", "boernepas.jpg", "godting.jpg", "phone.jpg", "visa.jpg", "money.jpg", "studere.jpg");
$begiven_pic_done = str_replace($begiven_pic_word, $begiven_pic_rep, $begiven_get);
echo "<br>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td>
<div class=\"calwrap\">
<div class=\"caltop\">$dag_m_done</div>
<div class=\"calbottom\">$dag_d</div>
</div>
<div class=\"posttop\">
<h1 class=\"pt\">$oversk</h1>
<div class=\"edit\"><a href=\"#\" onMouseover=\"showmenu(event,linkset[0])\" onMouseout=\"delayhidemenu()\"><img src=\"images/edit.gif\" alt=\"Edit\" /></a></div>
<a href=\"#\" style=\"background:url(images/calpics/$begiven_pic_done) no-repeat;\" class=\"user\">$begiven_word_done</a><a href=\"#\" class=\"com\">Kommentar (12)</a>
</div>
<div class=\"post\">
<p>$tekst</p>
</div>
</td>
</tr>
</table>";
}
?>
håber meget at i kan hjælpe med en løsning.