Solved

Changing table content with OnMouse events

Posted on 2006-11-30
12
250 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 Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP/VB email question 4 72
Index on a Table 6 36
Pass SQL to JSON. Page is in classic ASP and using Jquery 4 58
GitHub 1 39
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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