473,804 Members | 2,933 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 11311
bh***********@y ahoo.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>Editab le Table</title>
<script type="text/javascript">
/* this is what you need to change */
var tableTitles = ["Data Field 1","Somethin g Else","Third Data"];

var rowEditing = undefined;
var editWindow = undefined;
function editRow(e){
if (rowEditing) { // only one row at a time
if (editWindow && !editWindow.clo sed) {return false;}
else {
rowEditing = undefined;
editWindow=unde fined;
}
}
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("javascrip t:''","editWind ow","width=180, height=200");
writeEditPage(e ditWindow.docum ent);
}

function writeEditPage(d oc,cells) {
doc.open();
doc.write("<htm l><head><title> Edit Row "+(rowEditing.r owIndex+1)+
" Values <\/title><\/head>\n");
doc.write("<bod y onload='opener. populate(docume nt)'>\n<p>\n");
for(var i=0;i<tableTitl es.length;i++) {
doc.write("<lab el for='field"+i+" '>"+tableTitle s[i]+
": <input id='field"+i+"' type='text'><\/label>\n");
}
doc.write("<inp ut type='button' onclick='opener .rowCallback(do cument)'"+
" value='Ok'>");
doc.write("<\/p><\/body><\/html>\n");
doc.close();
}

function populate(doc) {
for(var i=0;i<tableTitl es.length;i++) {
doc.getElementB yId("field"+i). value = rowEditing.cell s[i].innerHTML;
}
}

function rowCallback(doc ){
if (!rowEditing) {return;} // something is wrong
for(var i=0;i<tableTitl es.length;i++) {
rowEditing.cell s[i].innerHTML = doc.getElementB yId("field"+i). value;
}
rowEditing = undefined;
editWindow.clos e();
}
</script>
</head>
<body>
<table>
<!-- table must have three columns when tableTitles have three elements -->
<thead>
<tr><td>Data Field 1</td><td>Somethin g Else</td><td>Third Data</td></tr>
</thead>
<tbody onclick="editRo w(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***********@y ahoo.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="whatev erFunction()">
<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.d ocument.getElem entById("td_1") .innerText
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("my Window.aspx?lab elling=whatever ","myWin","heig ht=
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
4842
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 the same page (in their own table) but I am not sure how to match up the array indexes to these values. I want to be able to display the array result as part of or nested in another table. Thanks in advance,
2
1733
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
1557
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" image needs to send that forms data to the function seen in the head. Firebird's javascript Console states that "form has no properties"
0
1936
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 length of this message, but hopefully it will help someone here give me the most concise and useful information, and perhaps help others out as well. :) It's been a while since I've had to design anything "real" for the web. I think the last...
0
1919
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 .NET and my understanding of some (but not all) of its concepts is a little sparse. I apologize for the length of this message, but hopefully it will help someone here give me the most concise and useful information, and perhaps help others out...
21
4001
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 nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
12
1766
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 a linked field. I want to be able to click this link, retreive the ID information for that record and then present detailed data for that record on the next page. How do I retreive the ID? Any hints are very much appreciated. Thanks
2
3584
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 uby/Rails. I started it in Perl and gave up on Perl as I went from the 'display the database information on the web page' to the 're-display the information from the database and allow the user to update the database using the web page' stage and realized...
1
4932
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 order, Input field and a submit button. The Category name is being fetched from the oracle db along with the corresponding Category order. In the corresponding input field (text box) the user enters a new category order which gets stored in...
0
10568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10311
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
10074
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...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
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
5516
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
4292
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
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2988
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.