Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-10-2006, 09:41 PM
New kid on the block
 
Join Date: Jun 2006
Location: Penang
Posts: 2
Rep Power: 0
gksm82 is on a distinguished road
Send a message via ICQ to gksm82 Send a message via MSN to gksm82 Send a message via Yahoo to gksm82 Send a message via Skype™ to gksm82
Exclamation how to pass the value from onmouseover in javacript to php..

Dear all,

please help me!!!
because i cant get the values from the functin i pass value...

sample code here :

<html>
<HEAD>
<script type="text/javascript">

// no right-click
function clickIE() { if (document.all) { }} function clickNS(e) { if (document.layers||(document.getElementById&&!docum ent.all)) { if (e.which==2||e.which==3) {}}} if (document.layers) { document.captureEvents(Event.MOUSEDOWN);document.o nmousedown=clickNS; } else { document.onmouseup=clickNS;document.oncontextmenu= clickIE; } document.oncontextmenu=new Function("return false")
// popup menu
var menuskin = "skin1";
var display_url = 1;

function showmenuie5(getid) {
var rowid=getid;
var rightedge = document.body.clientWidth-event.clientX;
var bottomedge = document.body.clientHeight-event.clientY;
if (rightedge < ie5menu.offsetWidth)
ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;
else
ie5menu.style.left = document.body.scrollLeft + event.clientX;
if (bottomedge < ie5menu.offsetHeight)
ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;
else
ie5menu.style.top = document.body.scrollTop + event.clientY;
ie5menu.style.visibility = "visible";
return false;
}
function hidemenuie5() {
ie5menu.style.visibility = "hidden";
}
function highlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "highlight";
event.srcElement.style.color = "white";
if (display_url)
window.status = event.srcElement.url;
}
}
function lowlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "";
event.srcElement.style.color = "black";
window.status = "";
}
}
function jumptoie5() {
if (event.srcElement.className == "menuitems") {
if (event.srcElement.getAttribute("target") != null)
window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
else
window.location = event.srcElement.url;
}
}

</SCRIPT>
<div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();">

<div class='menuitems' url='View.php?id=+rowid+'>View</div>
<div class='menuitems' url='Edit.php?id='+rowid+''>Edit</div>
<div class='menuitems' url='Delete.php?id='+rowid+''>Delete</div>
<div class='menuitems' url='Add.php?id='+rowid+''>Add New Record</div>
</div>

<style type="text/css">
<!--
.skin1 {
cursor:default;
font:menutext;
position:absolute;
text-align:left;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
width:120px;
background-color:menu;
border:1 solid buttonface;
visibility:hidden;
border:2 outset buttonhighlight;
}
.menuitems {
padding-left:15px;
padding-top:5px;
padding-bottom:5px;
padding-right:10px;
}
-->
</style>
</HEAD>
<body>
<script language="JavaScript1.2">
if (document.all && window.print) {
ie5menu.className = menuskin;
document.body.onclick = hidemenuie5;
} </script>
<?php

$ConnDB = mysql_pconnect ("localhost", "root" )or die("Could not connect.");
if(!$ConnDB)
die("no database");
if(!mysql_select_db("try",$ConnDB))
die("No database selected.");
extract($_POST);
extract($_GET);

$query="select * from Info order by id ASC";
$result=mysql_query($query) ;
$num=mysql_num_rows($result); ?>


<?
if($num>0){
for($j=1;$j<=$num;$j++) {
$row=mysql_fetch_array($result); ?>

<TABLE>
<tr onmousedown="if(window.event.button==2){ showmenuie5('<? echo $row[id] ?>'); }" onMouseOver="this.bgColor = '#C0C0C0'" onMouseOut ="this.bgColor = '#FFFFFF'" bgcolor="#FFFFFF">
<td><? echo "$row[F1]"; ?></td>
<td><? echo "$row[F2]"; ?></td>
<td><? echo "$row[F3]"; ?></td>
<td><? echo "$row[F4]"; ?></td>
</tr>
</table>

<?
}
}


?>
</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-10-2006, 01:28 AM
mysticmind's Avatar
Super Moderator
 
Join Date: Jun 2001
Location: Mystic Kingdoms
Posts: 2,687
Rep Power: 145
mysticmind will become famous soon enough mysticmind will become famous soon enough
Send a message via Yahoo to mysticmind
Hard to undersatnd what you want for..
what about using :
input type=hidden value='here'.
place it somewhere..
__________________
Personal's Blog! - Malaysian Artist!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-10-2006, 12:10 PM
New kid on the block
 
Join Date: Aug 2006
Location: Perak
Posts: 7
Rep Power: 0
chan0923 is on a distinguished road
From what i see, there're plenty of errors in your code...at least to me it seems so.. Here is the cleaner version of your code after tabulation...

PHP Code:
<html> 
<HEAD> 
<script type="text/javascript"> 

// no right-click 
function clickIE() { 
    if (document.all) {}

function clickNS(e) { 
    if (document.layers||(document.getElementById&&!docum ent.all)) { 
        if (e.which==2||e.which==3) {}
    }

if (document.layers) { 
    document.captureEvents(Event.MOUSEDOWN);
    document.o nmousedown=clickNS; 
} else { 
    document.onmouseup=clickNS;
    document.oncontextmenu= clickIE; 

document.oncontextmenu=new Function("return false") 

// popup menu 
var menuskin = "skin1"; 
var display_url = 1; 

function showmenuie5(getid) { 
    var rowid = getid;
    var rightedge = document.body.clientWidth-event.clientX; 
    var bottomedge = document.body.clientHeight-event.clientY; 
    if (rightedge < ie5menu.offsetWidth) 
        ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth; 
    else 
        ie5menu.style.left = document.body.scrollLeft + event.clientX; 
    if (bottomedge < ie5menu.offsetHeight) 
        ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight; 
    else 
        ie5menu.style.top = document.body.scrollTop + event.clientY; 
    ie5menu.style.visibility = "visible"; 
    return false; 
}

function hidemenuie5() { 
    ie5menu.style.visibility = "hidden"; 


function highlightie5() { 
    if (event.srcElement.className == "menuitems") { 
        event.srcElement.style.backgroundColor = "highlight"; 
        event.srcElement.style.color = "white"; 
        if (display_url) 
            window.status = event.srcElement.url; 
    } 


function lowlightie5() { 
    if (event.srcElement.className == "menuitems") { 
        event.srcElement.style.backgroundColor = ""; 
        event.srcElement.style.color = "black"; 
        window.status = ""; 
    } 


function jumptoie5() { 
    if (event.srcElement.className == "menuitems") { 
        if (event.srcElement.getAttribute("target") != null) 
            window.open(event.srcElement.url, event.srcElement.getAttribute("target")); 
        else 
            window.location = event.srcElement.url; 
    } 


</SCRIPT> 

<div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();"> 

<div class='menuitems' url='View.php?id=+rowid+'>View</div> 
<div class='menuitems' url='Edit.php?id='+rowid+''>Edit</div> 
<div class='menuitems' url='Delete.php?id='+rowid+''>Delete</div> 
<div class='menuitems' url='Add.php?id='+rowid+''>Add New Record</div> 
</div> 

</style> 
</HEAD> 

<body> 
<script language="JavaScript1.2"> 
if (document.all && window.print) { 
    ie5menu.className = menuskin; 
    document.body.onclick = hidemenuie5; 

</script>

<?php 

$ConnDB 
mysql_pconnect ("localhost""root" )or die("Could not connect."); 

if(!
$ConnDB
    die(
"no database"); 
if(!
mysql_select_db("try",$ConnDB)) 
    die(
"No database selected."); 

extract($_POST);
extract($_GET);

$query="select * from Info order by id ASC"
$result=mysql_query($query) ; 
$num=mysql_num_rows($result); 

?> 


<? 
if($num>0) { 
    for(
$j=1;$j<=$num;$j++) { 
        
$row=mysql_fetch_array($result); 
?> 

        <TABLE> 
        <tr onmousedown="if(window.event.button==2){ showmenuie5('<? echo $row[id?>'); }" onMouseOver="this.bgColor = '#C0C0C0'" onMouseOut ="this.bgColor = '#FFFFFF'" bgcolor="#FFFFFF"> 
        <td><? echo "$row[F1]"?></td> 
        <td><? echo "$row[F2]"?></td> 
        <td><? echo "$row[F3]"?></td> 
        <td><? echo "$row[F4]"?></td> 
        </tr> 
        </table> 

<? 
    

}

?>
The first strange thing i saw is right after you close the javascript tag

</SCRIPT>

<div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();">

<div class='menuitems' url='View.php?id=+rowid+'>View</div>
<div class='menuitems' url='Edit.php?id='+rowid+''>Edit</div>
<div class='menuitems' url='Delete.php?id='+rowid+''>Delete</div>
<div class='menuitems' url='Add.php?id='+rowid+''>Add New Record</div>


What does the 'rowid' means ? If it's a php variable, you should probably wrap a php start and close tag around it :
PHP Code:
Edit.php?id=<?php echo $rowid?>
.

Then I saw the last few lines :

PHP Code:
<tr onmousedown="if(window.event.button==2){ showmenuie5('<? echo $row[id?>'); }" onMouseOver="this.bgColor = '#C0C0C0'" onMouseOut ="this.bgColor = '#FFFFFF'" bgcolor="#FFFFFF"> 
<td><? echo "$row[F1]"?></td> 
<td><? echo "$row[F2]"?></td> 
<td><? echo "$row[F3]"?></td> 
<td><? echo "$row[F4]"?></td>
It's just not right to write $row[id] or <? echo "$row[F1]"; ?>. If id, F1, F2...are name of columns in your database, then it should be :
PHP Code:
<?php echo $row['id']; ?>
Explain more detail of what you're doing and what's your error. Your code tends to make things more complicated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
sending infor without pass to server? calvynlee Website Design 7 20-11-2006 11:42 AM
How to pass value from JSP scriptlet to JSP Tag? lcf Website Programming 3 11-06-2004 06:25 PM


All times are GMT +8. The time now is 01:52 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61