Solved

Changing table content with OnMouse events

Posted on 2006-11-30
12
211 Views
Last Modified: 2008-02-01
First of all, I must say that I am not a web developer, but I do have to serve as webmaster for a small entity in our firm. I have been asked to have a list of transactions that when moused over will cause more information on that transaction to be displayed in another cell of the table. My question is what would be the best approach to do this, DHTML, Javascript, or whatever. Also, if there is a good reference to look at while I am working on it, I would appreciate someone pointing it out.

Thanks.
0
Comment
Question by:sgeye
  • 4
  • 3
  • 2
12 Comments
 

Author Comment

by:sgeye
ID: 18047059
I guess I should have noted that our pages were developed using .ASP, which is why I placed this question in this section.
0
 
LVL 22

Expert Comment

by:WMIF
ID: 18047313
javascript will be a perfect solution for you.  there is a javascript topic area that you can ask in, but there are many experts that visit this topic area and javascript.  do you have a table cell already created that will house this data?
0
 
LVL 18

Expert Comment

by:SquareHead
ID: 18047341
IMO, "DHTML" is the answer, which is really javascript manipulating CSS. A good resource is the MSDN site here:

http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp
0
 

Author Comment

by:sgeye
ID: 18047788
The page already exists. Currently all of the transactions are listed in separate cells, but there are getting to be too many of them. Ideally there would be a menu like list, that when moused over would write the HTML for the transaction into the specified cell. I understand all of the individual pieces that make this work, but I am not sure how to put them all together. An example of something similar would be a great help.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 18

Accepted Solution

by:
SquareHead earned 25 total points
ID: 18047835
2 ways to approach this:

1. At page load, retrieve all transactions and their associated info and store on the page in hidden divs. The divs are hidden by setting the display style to none, like this:

<div id="div1" style="display:none;">transaction info</div>

In your menu, when the mouse rolls over the item, set the div's display style to "inline" -- OR -- use javascript to read the innerHTML from that DIV and put it into another container, the "specified cell".

2. Another approach would be to not retrieve all transaction info when the page loads, and instead, display your menu list. When a menu item is rolled over, use AJAX to retrieve the specific info from your database and display it -- using javascript -- in the "specified cell"...
0
 
LVL 18

Expert Comment

by:SquareHead
ID: 18048043
Here's an example of approach #1:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
      <title>Untitled</title>
      
<script language="JavaScript" type="text/javascript">
<!--
      function showTrans(transID){
            //alert(document.getElementById(transID).innerText);
            document.getElementById('targetDiv').innerText=document.getElementById(transID).innerText;
      }
//-->
</script>
</head>

<body>
<div id="trans1" style="display:none;">This is info for transaction #1.</div>
<div id="trans2" style="display:none;">This is info for transaction #2.</div>

<table>
<tr>
      <td><span id="1" onmouseover="showTrans('trans1');">Menu item 1</span></td>
</tr>
<tr>
      <td><span id="2" onmouseover="showTrans('trans2');">Menu item 2</span></td>
</tr>
<tr>
      <td>"specified cell"<br><div id="targetDiv" style="border:1px solid #cccccc;">zzz</div></td>
</tr>
</table>

</body>
</html>
0
 
LVL 22

Assisted Solution

by:WMIF
WMIF earned 25 total points
ID: 18048354
a third approach but similar to SquareHead's #1 would be to build a javascript array, and just change the content of the table cell.  actually looking at his sample, its closer than i first thought.  instead of creating a bunch of div tags, you can just build an array.  

@SquareHead - i am just curious why you would do that instead of an array?


<script language="JavaScript" type="text/javascript">
<!--
var arr(3)
<% loop through the values %>
arr(<%=number%>) = "<%=aspvarfromrecordset%>
<% end loop %>
     function showTrans(transID){
          //alert(document.getElementById(transID).innerText);
          document.getElementById('targetDiv').innerText = arr(transID);
     }
//-->
</script>
0
 
LVL 18

Expert Comment

by:SquareHead
ID: 18048382
@WMIF -- because I am not that good at javascript :-)  Agreed, an array is a better choice than a bunch of divs...
0
 
LVL 22

Expert Comment

by:WMIF
ID: 18048413
>>because I am not that good at javascript :-)  

haha, that is exactly why i was wondering about what you did because i am not that great at javascript either. :)  
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now