hi all,
I am developing a blog where in the administrator controlled panel I can view users comments in a table format.

the problem is now i want to view a link to edit page when i bring the mouse pointer to on a comment
then i wish to click it and navigate to my editing page.

I am new to java script .

I do this with php .

can you tell me or give a hint to accomplish this???

if there is a example coding, highly appreciated.

thanks in advance,
menuka

Recommended Answers

All 5 Replies

<div><b><a href='edit.php?articleid=1'>My article 1</a> </b>
content 1 content 1 content 1 content 1 content 1
 
</div>


<div><b><a href='edit.php?articleid=2'>My article 2</a> </b>
content 2 content 2 content 2 content 2 content 2
 
</div>

<div><b><a href='edit.php?articleid=3'>My article 3</a> </b>
content 3 content 3 content 3 content 3 content 3
 
</div>

Here an example using CSS visibility, edit menu on each comment will appear every time you point mouse to each comment. see the result in "View edit menu using visibility CSS", and download the complete code

<html>
<head><title>View Edit Menu with CSS</title>
<style>
.comment{margin : 10px 0; width : 400px; border : 1px solid #000000; padding : 5px;}
.comment span{display : block; visibility : hidden;}
div:hover span{visibility : visible;}
</style>
</head>
<body>
<div class="comment" id="comment1">
<span id="menu1"><a href="edit.php?id=1">Edit</a></span>
Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 Comment 1 
</div>
<div class="comment" id="comment2">
<span id="menu2"><a href="edit.php?id=2">Edit</a></span>
Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2 Comment 2
</div>
<div class="comment" id="comment3">
<span id="menu3"><a href="edit.php?id=3">Edit</a></span>
Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 Comment 3 
</div>
</body>
</html>

hi thanks for ur replies but i try to do in differnt way

here is the code of javascript

function show(element)
{
    element.style.visibility = 'visible';
}

function hide(element)
{
    element.style.visibility = 'hidden';
}

here is the rest of coding to print table that bring data from db

include '../../Classes/DBhandling.php';
             include '../../Classes/config.php';

 $dob = new DBhandling(dbHost,dbUser,dbName,dbPass);
 $dob->connectDB();


$qry="select * from usercomments";
        $result=mysql_query($qry);
            echo '<table  border=1 align="center">'.'<thead>'.'<tr>'.'<th>'."PO_ID".'</th>';
            echo '<th>'."C_ID".'</th>'.'<th>'."USER_NAME".'</th>'.'<th width=300; align="center">'."COMMENT".'</th>';
            echo '<th>'."DATE".'</th>';
            echo '<th>'."ALLOW".'</th>';
            echo '<th>'.'DEL'.'</th>'.'</tr>';
            echo '</thead>';
        while($row=mysql_fetch_array($result)){
           echo '<tbody>';
           echo '<tr>'.'<td align="center" >'.$row['postId'].'</td>';
           echo '<td align="center" >'.$row['commentId'].'</td>';
           echo '<td align="center"  >'.$row['name_cm'].'</td>';
           ?><form>
               <td>
               <div onmouseover="show(document.getElementById('link'));" onmouseout="hide(document.getElementById('link'));">
               <?php echo $row['comment_cm'] ?>
               <a href="aa.php" id="link" >Edit</a>
               </div>
               </td>
           </form>
           <?php
           echo '<td align="center" >'.$row['dateComment_cm'].'</td>';
           //echo '<td align="center" >'.$row['allow_cm'].'</td>';
             
           $cmId=$row['commentId'];
           $poId=$row['postId'];
           echo '<td align="center" >';
           $radioval=$row['allow_cm'];
    
          echo '<br>';
        if ($radioval==1){

             echo     '<form action="">';
             echo     "Yes"."<input type='radio' name='but' value='1' checked='checked' id='id'.'$cmId'.'$poId' onclick='callChange(this.value,".$cmId.",".$poId.")'/>";
             echo "No".'&nbsp'.'&nbsp'."<input type='radio' name='but' value='0'    id='del'.'$cmId'.'$poId'  onclick='callChange(this.value,".$cmId.",".$poId.")'/>";
             echo      '</form>';
             
        }
       if($radioval==0){
            echo     '<form action="">';
           
            echo "Yes"."<input type='radio' name='but' value='1'   id='del'.'$cmId'.'$poId'  onclick='callChange(this.value,".$cmId.",".$poId.")' />";
            echo "No".'&nbsp'.'&nbsp'."<input type='radio' name='but' value='0' checked='checked' id='del'.'$cmId'.'$poId'  onclick='callChange(this.value,".$cmId.",".$poId.")'/>";
            echo      '</form>';
            
        }
        
           echo '</td>';
           
           
         
           echo "<td align='center'><input type='button' value='Del' id='del'.'$cmId'.'$poId' onclick='delcomment(".$cmId.",".$poId.")'>"."</td>";
           
           echo '</tr>';
       
           
           
        }
         echo '</tbody>'.'</table>';
        $dob->closeDB();

problem is
when i run the code only the first row of the table view the link when the mouse is over the row.

when i go to other rows in the table still the link will be displayed only in the first row .how to solve this.
thanks in advance,
meunka

I am modifying 23,24,25 line of your code. Id must be unique so you are giving same id to all rows.
Use commentid to set id of TD.

<div onmouseover="show(document.getElementById('link<?php echo $row['commentId']?>'));" 
onmouseout="hide(document.getElementById('link<?php echo $row['commentId']?>'));">               
<?php echo $row['comment_cm'] ?>               
<a href="aa.php" id="link<?php echo $row['commentId']?>" >Edit</a>
commented: good answer +1

thanks dear .... u save my time...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.