Solved

Changing table content with OnMouse events

Posted on 2006-11-30
12
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 informatio…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 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