473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

swap div is only getting style:none value

Hi,

I'm been struggling with this for a week now, I'm new to javascript so please bear with me.

What I have been trying to do is get the div to swap once you go over a <td>, at the moment the when you point on one of the <td> it takes the div away. My code gets data from the database, I have tested if it gets the right, and that is correct. I'm sure it's something in my javascript, I have a feeling it's got to do with this piece of code:

Code:
Expand|Select|Wrap|Line Numbers
  1. if (arr[i].id != "navtxt" && arr[i].id.substr(0,5) != "style" && arr[i].id.substr(0,5) != "arrow" && arr[i].id != "" && arr[i].id != "mediaspace") {
  2.  
  3.                 arr[i].style.display = 'none';
  4.  
Here is the complete code:
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2.  
  3. function showDiv(elem)
  4.  
  5. {
  6.  
  7.         var arr = document.getElementsByTagName('div')
  8.  
  9.         for(var i=0; i<arr.length;i++)
  10.  
  11.         {
  12.  
  13.             if (arr[i].id != "navtxt" && arr[i].id.substr(0,5) != "style" && arr[i].id.substr(0,5) != "arrow" && arr[i].id != "" && arr[i].id != "mediaspace") {
  14.  
  15.                 arr[i].style.display = 'none';
  16.  
  17.                 var styler = document.getElementById("style1_"+arr[i].id);
  18.  
  19.                 styler.className = "stylegray";
  20.  
  21.                 var styler = document.getElementById("style2_"+arr[i].id);
  22.  
  23.                 styler.className = "stylegray";
  24.  
  25.             }
  26.  
  27.         }
  28.  
  29.  
  30.  
  31.         var arr = document.getElementsByTagName('img')
  32.  
  33.         for(var i=0; i<arr.length;i++)
  34.  
  35.         {
  36.  
  37.             if (arr[i].id.substr(0,5) == "arrow") {
  38.  
  39.                 arr[i].src = 'images/blank.jpg';
  40.  
  41.             }
  42.  
  43.         }
  44.  
  45.  
  46.  
  47.         var arr = document.getElementsByTagName('a')
  48.  
  49.         for(var i=0; i<arr.length;i++)
  50.  
  51.         {
  52.  
  53.             if (arr[i].id.substr(0,7) == "style3_") {
  54.  
  55.                 var styler = document.getElementById(arr[i].id);
  56.  
  57.                 styler.style.color = "#e3e3e3";
  58.             }
  59.         }
  60.  
  61.         e2 = document.getElementById(elem);
  62.  
  63.         e2.style.display = 'block';
  64.  
  65.         e3 = document.getElementById("style1_"+elem);
  66.  
  67.         e3.className = "stylered";
  68.  
  69.         e3 = document.getElementById("style2_"+elem);
  70.  
  71.         e3.className = "stylegray2";
  72.  
  73.         e3 = document.getElementById("style3_"+elem);
  74.  
  75.         e3.style.color = "darkred";
  76.  
  77.         e3 = document.getElementById("arrow_"+elem);
  78.  
  79.         e3.src = "http://bytes.com/images/arrow.png";
  80. }
  81.  
  82. </script>
  83.  
  84. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="word-wrap: break-word; table-layout: fixed; height: 130px">
  85.                             <tr>
  86.                             <?                            foreach ($niceArray AS $key => $value) {
  87.  
  88.                             $i++;
  89.                             $bstyle = "border-right-width: 2px; border-right-style: solid; border-right-color: #e3e3e3;";
  90.                                         if ($i == $numrows) {
  91.                                             $bstyle = "";
  92.                                         }
  93.                                         $color1 = "stylegray";
  94.                                         $color2 = "stylegray";
  95.                                         $color3 = "#e3e3e3";
  96.                             $arrow = "http://bytes.com/images/blank.jpg";
  97.                             if ($first) {
  98.                             $first = false;
  99.                             $firstDiv = $value["showDiv"];
  100.  
  101. }
  102. ?>
  103.                             <td align="left" style="<?=$bstyle?> padding-left: 10px; padding-right: 10px;" width="<?=$sizer?>%" onmouseover="javascript:showDiv('<?=$value["showDiv"]?>');"  valign="top">
  104.  
  105. <center><img id="<?=$value["id"]?>" width="12px" height="12px" src="<?=$arrow?>" /></center>
  106.  
  107. <br />
  108.  
  109. <b>
  110. <div id='style1_<?=$value["showDiv"]?>' class="<?=$color1?>"><?=strtoupper($value["file_type"])?></div>
  111. </b>
  112.  
  113. <br />
  114.  
  115. <?php if ($value['file_type'] != 'Video') {?> <a id='style3_<?=$value["showDiv"]?>' href="<?=$value['click']?>" style="color: <?=$color3?>; text-decoration: underline; font-size:11px;" target="_blank">Click here to view</a> <? } ?>
  116.  
  117. <br />
  118. <br />
  119.                             <a href="javascript:showDiv('<?=$value["showDiv"]?>');">
  120.                             <div id='style2_<? echo $value["showDiv"];?>'class="<?=$color2?>"><?=$value["file_name"]?></div>
  121. </a>
  122.  
  123. <br />
  124. </td>
  125. <?}?>
  126.  
  127. <script language="javascript">showDiv('<? echo $firstDiv;?>');
  128. </script>
  129.  
If someone could please point me in the right direction I would really appreciate it.

Thanks
May 10 '12 #1
1 1520
Rabbit
12,516 Expert Mod 8TB
Yes, that will set the display to none. I don't know what you question is.
May 10 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Elvis V. | last post by:
Good morning, I have a table with three fields, Buildings, Floors and Rooms. This is what I would like to do; in my form when I select Building1 in my drop down box for Buildings, when I go to the...
12
by: LAshooter | last post by:
I have a portfolio page which loads a dozen thumbnails and one large image. A friend helped me code a script (below) which will swap out the large image (named "imgLarg") when a different thumbnail...
1
by: somanyusernamesaretakenal | last post by:
Hi everyone, I am working with Access 2003. I know a crosstab query only allows 1 value field, but how to do you around this restriction? I have a table with let’s say customers, products,...
2
by: Arnold | last post by:
Hi there, In a textbox containing a string of ID numbers each separated by a comma, how can I keep only the first value, and then remove all of the other numbers and commas behind it? The first...
2
by: emeryk | last post by:
I am trying to loop through a gridview and insert the selected value of a dropdown list and textbox from each row into another table. I was finally able to get the insert statment to work but it...
1
by: rag84dec | last post by:
hi, I have the following code to get the button's value..It is giving empty string.... Can anyone help in getting the value of type button <form name='rag' action='tt.asp' method='post'>...
13
by: mcfly1204 | last post by:
The following query only returns one value when several are expected. SELECT @contactid = Con.CONTACTID, @accountid = Con.ACCOUNTID, @lastname = LASTNAME, @firstname = FIRSTNAME, @email = EMAIL,...
9
vikas251074
by: vikas251074 | last post by:
I am not getting date value in spite of my good effort. This code was working in my last office where I work. Now I am trying to work at my home pc. but not getting date value. Any can help me why...
3
by: Gilda Horgan | last post by:
Hi all, I have created an image map for my home page with multiple hot spots that swap out the main image for another. It is built in a gallery with CSS and html. I started with a template and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.