www.webdeveloper.com
Results 1 to 2 of 2

Thread: javascript onmouseover table cell

  1. #1
    Join Date
    Jun 2006
    Location
    Doncaster
    Posts
    78

    javascript onmouseover table cell

    Hi,
    I'm working with the output of a database to make a drama script editable.
    The php reads the chapter number and text inot two cells, which I then want to manipulate with javascript.

    This is the php:
    PHP Code:
    <?php
    require_once('mysql_login.php');
    $query "SELECT * FROM script";
    $scripttxt mysql_query($query);
    //mysql_close();
    echo "<table border='0'>";
    echo 
    "<tr> <th>Chapter</th> <th>Text</th></tr>";
    // keeps getting the next row until there are no more to get
    while($row mysql_fetch_array($scripttxt)) {
        
    // Print out the contents of each row into a table
        
    echo "<tr onmouseover=\"editarea\"()\" style=\"display:none\"><td><strong>"
        echo 
    $row['chapter'];
        echo 
    "</strong></td><td>"
        
    //construcr textfile
        
    include ("Chapter0".$row['chapter'].".txt");
        echo 
    "</td></tr>";   


    echo 
    "</table>";
    ?>
    ...which works as a plain echo "<tr> (etc), but breaks when the following javascript is used in an external file:
    Code:
    <script type="text/javascript">
    function displayeditarea()
    {
    onmouseover="this.bgColor='#ffffff';"; 
    onmouseout="this.bgColor='#FFCC66';";
    onmouseover="edit.style.display = "";"; 
    onmouseout="edit.style.display = "none";"; 
    }
    </script>
    An example of what I am aiming for is on Netvibes, where the news sories show some options onmouseover and more functions onclick.

  2. #2
    Join Date
    May 2009
    Posts
    150
    Events such as onmouseover need attaching to an element, otherwise the browser doesn't know what to detect the mouse being over:

    https://developer.mozilla.org/En/DOM/Event
    https://developer.mozilla.org/en/DOM...dEventListener
    http://en.wikipedia.org/wiki/DOM_Events

    That's a few links to get you started on events.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles