Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Changing table content with OnMouse events

Posted on 2006-11-30
12
Medium Priority
?
264 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
Independent Software Vendors: 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!

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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 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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

719 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