473,654 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table Object: rows[] and cells[]

Is there a way to specify more than one row or cell collection in the
JS table object? Consider this:

var x=document.getE lementById('myT able').rows[1].cells
x[0].innerHTML="NEW CONTENT"

This selects the second row (rows[1]) and the first cell (x[0]). How
would I select the first and second rows, and first - fifth rows, for
example? I would think something like the following:

var x=document.getE lementById('myT able').rows[0,1].cells
x[0,1,2,3,4].innerHTML="NEW CONTENT"

or perhaps

var x=document.getE lementById('myT able').rows[0-1].cells
x[0-4].innerHTML="NEW CONTENT"

But neither works. Any suggestions? A test example is here:
http://www.w3schools.com/js/tryit.as...tablerow_cells.

Jun 20 '06 #1
2 2955


e271828 wrote:

var x=document.getE lementById('myT able').rows[0,1].cells
x[0,1,2,3,4].innerHTML="NEW CONTENT"


Write two nested loops then that do the job.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 20 '06 #2
Martin Honnen wrote on 20 jun 2006 in comp.lang.javas cript:
e271828 wrote:
var x=document.getE lementById('myT able').rows[0,1].cells
x[0,1,2,3,4].innerHTML="NEW CONTENT"


Write two nested loops then that do the job.


Write a function:

function fillCell(r,c,t) {
var x=document.getE lementById('myT able');
x.rows[r].cells[c].innerHTML = t;
};

test it:

fillCell(0,0,"N EW CONTENT");

and then go a-looping as Martin suggested if the above works.

for(var r=0;r<2;r++)
for(var c=0;c<5;c++)
fillCell(r,c,"N EW CONTENT");

not tested.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3540
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say black for example). I am dynamically creating the LinkButton controls and adding them into the table cell and I've also hooked up an event handler for each LinkButton's Click event. This all works fine. Now in the Link Button's Click event...
5
36850
by: Richard Dixson | last post by:
I created a new C# web application. Basically all I am trying to do is create a table that consists of a few rows with two columns in each. And then to set those columns to text values from my code behind. However I am not able to do this at all, I am going about this wrong, I think and need guideance. If this was just straight HTML I would do this: <table> <tr><td>field 1</td><td>value 1 set by code behind</td></tr>
1
7339
by: kingster | last post by:
Hi, I have a regular dataset and all i want to do is make a pivot table display in a browser with the datasource of the pivot table to be this dataset and then the end-user will be able to do whatever they want ... i dont need to do any special formatting just a straigh ot pivot tables usign sql server, asp.net, vb.net, OWC 10
0
2087
by: loga123 | last post by:
Hi All, I am very new to .net and trying to develop a small application. I am using asp .net 2.0. I have a table control (server) in my code that has header row like this. <asp:Table id="Table1" GridLines="Both"
5
4933
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes. There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)? Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html Here is some jquery js that I think...
0
8375
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8482
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.