473,388 Members | 1,408 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,388 software developers and data experts.

How would I go about dynamically adding the <span> tags as innerHTML?

shelzmike
I have a issue, which I am thinking might not be that difficult.

How would I go about dynamically adding the <span> tags as innerHTML (and consequently replacing what is currently in each cell) before the visibility changes.

Seems to be I would first have to collect all of the nodeValues first, then loop through each cell and add an innerHTML of essentially this: '<span>' + nodeValues[i] + <'\span>

Now, I am aware that this is not proper syntax, I am merely illustrating a point. But is this logical and possible?

Mike
Oct 12 '11 #1
3 1825
Answered my own question - it was actually pretty easy.

Expand|Select|Wrap|Line Numbers
  1. function hideRawData() {
  2.     var tbl = document.getElementById("users_table");
  3.     var tblRows = tbl.getElementsByTagName("tr");
  4.     var rawData = tbl.getElementsByTagName("td");
  5.  
  6.     for (k=0; k < rawData.length; k++){
  7.         //alert(rawData[k].firstChild.nodeValue);
  8.         rawData[k].innerHTML = "<span>" + rawData[k].firstChild.nodeValue + "</\span>";
  9.     }
  10.  
  11.     for(j = 0; j < rawData.length; j++) {
  12.         //rawData[j].style.display = "none";
  13.         rawData[j].firstChild.style.visibility = "hidden";
  14.     }
  15.  
  16.    // alert ("Raw data has been hidden")        
  17. } // end hideRawData
Oct 12 '11 #2
Dormilich
8,658 Expert Mod 8TB
note: HTML does not use backslashes, i.e. "</\span>" should be "</span>" (\s is a RegExp for whitespace)
Oct 13 '11 #3
Yeah, I didn't mean to do that. Luckily it still worked, but I have since fixed it. Thanks!

Mike
Oct 13 '11 #4

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

Similar topics

1
by: bjam | last post by:
Hi, I am trying to create a sort of include file into my xsl files such that calling the following template will push these xml tags into my document such that the other xsl files can use these...
3
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound...
10
by: David | last post by:
Can anyone give me a quick code snippet (that is standards-based) for adding OPTION tags to a SELECT dynamically. I have no problem doing it in IE but I am kind of new to the whole standards world...
11
by: Steven D'Aprano | last post by:
Suppose I create a class with some methods: py> class C: .... def spam(self, x): .... print "spam " * x .... def ham(self, x): .... print "ham * %s" % x .......
1
by: James Black | last post by:
You can see the program at: http://dante.acomp.usf.edu/CommunicationSimulator/index.php I am trying to dynamically add script tags to my webpage, but I get an error that the first javascript...
3
by: Ben Dewey | last post by:
Okay, so I have a base Page class called ArticlesPageBase. This base class has reads in an overridable ArticleId and Loads the data into a Panel object in the ContentPlaceHolder of the Master. ...
1
by: Tor Inge Rislaa | last post by:
Adding HTML tags to data from SQL server When dragging a table on to a web form in an ASP.NET 2.0 application, the connection is established and the data is displayed in a DataGrid. Is it...
5
by: J | last post by:
I am having problems dynamically adding more than one event handler to an input. I have tried the Javascript included at the bottom. The lines inp.attachEvent('onkeyup',...
5
by: Liquidtouch | last post by:
I'm not much of a HTML or Javascript programmer but have a little experience just hacking away at it. I am creating a HTML application and would like to be able to add or remove rows of a table....
4
by: Lewis Holmes | last post by:
Hi I have the following situation in one of my asp.net pages. The user can add multiple table rows to a form by selecting a button. These rows can contain asp.net controls. When this button is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.