473,498 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting values from html data table to another web page

Hi there ,
I am pretty new at javascripting and i am having this huge problem. I
am using asp.net and C# webapplication.

In my asp.net aspx file I have a place holder for taking an html table
dynamically. I create a html table Time | Data1 | Data2 | Data3 type,
in which the columns are not fixed, hence i am building it dynamically
in c# code.

now after i have the html table in the webpage, I want to give user to
functionality to edit any row that is clicked. I want to open a new
editing window where user can edit the row.

The problem is that what would be a good idea to have a edit window.
2. How will i know which row is clicked.
3. How do i get the values from the row clicked in this new window.
4. How do i dynamically create labeles inside that window to edit
because the fields depend on the table.

Any help will be appreciated. I am so badly behind schedule.

Thanks
Bhavin
Jul 20 '05 #1
2 11291
bh***********@yahoo.com (Bhavin G) writes:
The problem is that what would be a good idea to have a edit window.
2. How will i know which row is clicked.
When you click it, the click event will point to either the row itself,
or one of its children. Find the row and keep it in a global variable.
3. How do i get the values from the row clicked in this new window.
In the new window, "opener" refers to the opening window, and you can
access its global variables, including the one pointing to the correct
row.
4. How do i dynamically create labeles inside that window to edit
because the fields depend on the table.
Labels?

You will know the table structure when you build the page server-side,
so you can generate Javascript that creates a page with the correct
names and number of fields. The simplest way to put content into the
new window is with the window.write function.
Any help will be appreciated. I am so badly behind schedule.


Hire me, it's cheap :)
Try this example code:
---
<html>
<head>
<title>Editable Table</title>
<script type="text/javascript">
/* this is what you need to change */
var tableTitles = ["Data Field 1","Something Else","Third Data"];

var rowEditing = undefined;
var editWindow = undefined;
function editRow(e){
if (rowEditing) { // only one row at a time
if (editWindow && !editWindow.closed) {return false;}
else {
rowEditing = undefined;
editWindow=undefined;
}
}
e = e || window.event; // IE sucks
var tgt = e.target || e.srcElement; // IE sucks
while (tgt && !tgt.cells) {tgt = tgt.parentNode;} // finds tr.
rowEditing = tgt;
editWindow = open("javascript:''","editWindow","width=180,heigh t=200");
writeEditPage(editWindow.document);
}

function writeEditPage(doc,cells) {
doc.open();
doc.write("<html><head><title>Edit Row "+(rowEditing.rowIndex+1)+
" Values <\/title><\/head>\n");
doc.write("<body onload='opener.populate(document)'>\n<p>\n");
for(var i=0;i<tableTitles.length;i++) {
doc.write("<label for='field"+i+"'>"+tableTitles[i]+
": <input id='field"+i+"' type='text'><\/label>\n");
}
doc.write("<input type='button' onclick='opener.rowCallback(document)'"+
" value='Ok'>");
doc.write("<\/p><\/body><\/html>\n");
doc.close();
}

function populate(doc) {
for(var i=0;i<tableTitles.length;i++) {
doc.getElementById("field"+i).value = rowEditing.cells[i].innerHTML;
}
}

function rowCallback(doc){
if (!rowEditing) {return;} // something is wrong
for(var i=0;i<tableTitles.length;i++) {
rowEditing.cells[i].innerHTML = doc.getElementById("field"+i).value;
}
rowEditing = undefined;
editWindow.close();
}
</script>
</head>
<body>
<table>
<!-- table must have three columns when tableTitles have three elements -->
<thead>
<tr><td>Data Field 1</td><td>Something Else</td><td>Third Data</td></tr>
</thead>
<tbody onclick="editRow(event)">
<tr><td>Row on</td><td>Hello</td><td>There</td></tr>
<tr><td>Row too</td><td>Hello</td><td>Again</td></tr>
<tr><td>Row tree</td><td>Hello</td><td>Larch</td></tr>
<tr><td>Row for</td><td>Hello</td><td>Peace</td></tr>
</tbody>
</table>
</body>
</html>
---

Ask if there is something.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
In article <86**************************@posting.google.com >,
bh***********@yahoo.com enlightened us with...

The problem is that what would be a good idea to have a edit window.
2. How will i know which row is clicked.
Use onClick.
<tr id="whatever" onClick="whateverFunction()">
<td id="td_1">text</td>
</tr>
3. How do i get the values from the row clicked in this new window. Assuming new browsers only...
window.opener.document.getElementById("td_1").inne rText
4. How do i dynamically create labeles inside that window to edit
because the fields depend on the table.


Pass something as an argument. You can use the url. Say you're going to
open a new window...
window.open("myWindow.aspx?labelling=whatever","my Win","height=
400,width="400");
--
-------------------------------------------------
~kaeli~
Black holes were created when God divided by 0.
Not one shred of evidence supports the notion
that life is serious.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #3

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

Similar topics

2
4829
by: John Wilson | last post by:
Hello friends, I have this dynamic array(shown below) that I need to match to values (1 - 10) that I am returning from the database via DSN connection object. The values I need to match are on...
2
1710
by: spiderman | last post by:
Hi, How can I getting parameter values from more than 1 HTML form onto the same ASP page? Thank you
1
1530
by: Sam Wuebben | last post by:
I've been trying to get the values of hidden fields from one of many forms on a page to load into a function. The test page is at: http;//www.mvldesign.com/test/item_pop.html The 'Add to Cart"...
0
1900
by: Jim | last post by:
I need some help getting started with a .NET web project for a commercial site. I am new to .NET and my understanding of some (but not all) of its concepts is a little sparse. I apologize for the...
0
1879
by: Jim | last post by:
This si a repost, I apologize but perhaps my original inquiry got buried under all the usenet spam... I need some help getting started with a .NET web project for a commercial site. I am new to...
21
3924
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
12
1723
by: Lennart Anderson | last post by:
I'm having a MySQl table wih a lot of information. I want to present some main fields in a table on one page. Each record do, of course, have a unique ID. The presnted table will have one field as...
2
3546
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
1
4895
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category...
0
7002
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
7203
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
6885
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
7379
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...
1
4908
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
3093
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
1417
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 ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
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.