473,486 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can I change column values in dynamic table

2 New Member
I got from AJAX query a string like this:
Expand|Select|Wrap|Line Numbers
  1. var ansverStr = "[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"15\",\"Regent Street\",1343329406000]\r\n
  2. [1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"13\",\"Golders Green\",1343329883000]\r\n
  3. [1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"176\",\"Tottenham Ct Rd\",1343329612000]"
... etc
Created a dynamic table to expose the data:
Expand|Select|Wrap|Line Numbers
  1. var element;
  2. element = '' + ansverStr.split('\r\n').map(function(line){ return '' + JSON.parse(line).map(function(cell){ return '' + cell + ''; }).join('') + ''; }).join('') + ''; document.getElementById("bStop").innerHTML=element;
The last field in ansverStr substrings is a time.

The question: How can I access to those values in this column in dynamic table to convert them into time format
Jul 27 '12 #1
2 1798
Frinavale
9,735 Recognized Expert Moderator Expert
Like this:
Expand|Select|Wrap|Line Numbers
  1. var ansverStr = "[1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"15\",\"Regent Street\",1343329406000]\r\n    [1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"13\",\"Golders Green\",1343329883000]\r\n [1,\"Bedford Street\",\"Oxford Circus, Green Park or Westminster\",\"176\",\"Tottenham Ct Rd\",1343329612000]";
  2.  
  3. var lines = ansverStr.split('\r\n');
  4.  
  5. var elementContent= "";
  6.  
  7. for(lineIndex = 0; lineIndex<lines.length; lineIndex++) {
  8.     var row = JSON.parse(lines[lineIndex]);
  9.  
  10.     for (i = 0; i < row.length; i++) {
  11.         var rowData = row[i];
  12.         if (i == row.length - 1) {
  13.             var d = new Date(rowData);
  14.             elementContent = elementContent + " " + d;
  15.         } else {
  16.             elementContent = elementContent + " " + rowData;
  17.         }
  18.     }
  19.  
  20.      elementContent = elementContent + "<br /> "
  21.  
  22. }
  23.  
  24. document.getElementById("bStop").innerHTML = elementContent;
-Frinny
Jul 27 '12 #2
Sakunne
2 New Member
Thanks, the most elegant solution :)
Jul 27 '12 #3

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

Similar topics

1
1777
by: daisy | last post by:
Can anyone point me to the syntax on how to fetch indiviual column values from the current row in a datagrid on a button click in C# or VB.
3
3137
by: ssb | last post by:
Hello, This may be very elementary, but, need help because I am new to access programming. (1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor ?) the values one by one and...
3
2607
by: hazz | last post by:
The datareader below contains two rows of two columns but in the for loop, the values for only the first row are getting printed twice. How do I get to the values of the second row? Thanks. -hazz...
0
3962
by: jeoffh | last post by:
Background: I am trying to "merge" some attributes into an existing XML column in my MS SQL 2005 database. The general idea is that I have an XML column in a table and I would like to update/delete...
1
3736
by: san1014 | last post by:
Hi I have a table SQL> select * from nodes; NODE_ID NODE_NAME -------------------- ------------------------------ N1 Kothhapet N2 Nagole...
1
1365
by: gkinu | last post by:
Application-Generated Column Values in DataGridView on New Record I have a DataGridView which I am using to enter new records to a table with 5 columns/fields. However, values for two of the...
1
1174
by: Shikha1234 | last post by:
Hi, I have a database which has a primary key field (integer). It should be autogenerated on every insert statement. I am hardcoding it everytime to remove the error that the data supplied is...
1
1824
by: CreativeMind | last post by:
hi all , actually i am binding a datagrid with a dataview which has a datatable showing output like this.. propertyid viewname 1 fronside 1 lefttside 1 ...
5
5139
by: Nelson Joseph | last post by:
Hi All, I have a file which contains set of data in the following format. Title1 Title1, Title2, Title3 A B C D 1 1 1 1 2 3 4 6
0
6967
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
7132
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
7180
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...
1
6846
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...
1
4870
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...
0
3076
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
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...

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.