Solved

Changing table content with OnMouse events

Posted on 2006-11-30
12
227 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iis reverse proxy virtual directory 8 134
Saving more than one value from multiple drop down menu 14 51
Server Timeout with Loop 6 38
Microsoft SQL ADO Conn Issue 6 40
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

861 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

24 Experts available now in Live!

Get 1:1 Help Now