473,568 Members | 2,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic table creation - table row index

3 New Member
Hi,

I am creating table rows dynamically using javascript.I have dropdowns in the dynamically created row and onchange of the row i am using ajax call to populate the values to another dropdown wchih is also dynamicaaly created.
Please find the code below

function createRow()
{
var tbody = document.getEle mentById("t1");
var newTr = document.create Element("TR");
var newTd1 = document.create Element("TD");
var ss=document.get ElementById("ta sk1").innerHTML ;
newTd1.innerHTM L = document.getEle mentById("task1 ").innerHTM L;
newTd1.setAttri bute("align","c enter");
var newTd2 = document.create Element("TD");
newTd2.innerHTM L = document.getEle mentById("activ ity1").innerHTM L;
newTd2.setAttri bute("align","c enter");
newTr.appendChi ld(newTd1);
newTr.appendChi ld(newTd2);
tbody.appendChi ld(newTr); }


span id="task1" style="visibili ty:hidden" property="task1 ">

<html:select styleId="tasks" property="tasks " onchange="hi('l oadactivities.d o?taks=' + this.value);cre ateRow();">

<option value="All">----</option>
<bean:define id="hoursCollec tion" name="loginForm " property="task" />
<logic:presen t name="hoursColl ection">
<logic:iterat e id="hour" name="hoursColl ection">
<html:option value="<%=(Stri ng)hour%>"><%=( String)hour%></html:option>
</logic:iterate>
</logic:present>
</html:select>
</span>
<span id="activity1" style="visibili ty:hidden">
<html:select styleId="activi tys" property="activ itys" >
<option value="All">----</option>

<bean:define id="activityCol lection" name="loginForm " property="subta sks" />
<logic:presen t name="activityC ollection">
<logic:iterat e id="hour" name="activityC ollection">
<html:option value="<%=(Stri ng)hour%>"><%=( String)hour%></html:option>
</logic:iterate>
</logic:present>
</html:select>
</span>



i have a ajax call in the "task" which whill return the activities to the "activities " dropdown.But since i dont have the ids of the activity..where ever i change the task the result is coming int he first row...can anyone please help me...

If what i am doing is not a good way please give me another solution....
thanks in advance....
Apr 4 '07 #1
5 10512
christy2007
3 New Member
Hi,

i have a dynamicalay created table whcih have a select box.How can i know inisde a script whcih table row i have selected(index of the row) if i select a particaular select box say the the select box in the fifth row?

Thanks in advance
Apr 4 '07 #2
moho
21 New Member
Hi,

i have a dynamicalay created table whcih have a select box.How can i know inisde a script whcih table row i have selected(index of the row) if i select a particaular select box say the the select box in the fifth row?

Thanks in advance
1 check the parentNode of the selectbox, probably a td
2 check it's parent,
3 get the row then use the rowIndex.
Apr 4 '07 #3
christy2007
3 New Member
1 check the parentNode of the selectbox, probably a td
2 check it's parent,
3 get the row then use the rowIndex.

Hi thankyou for your reply

i did like this
i called a function in the onchange of the selectbox say onchange="getin dex(this)";

function getindex(tbody) {
alert(tbody.par entNode.rowInde x);
}

Its coming as undefined..Can u please help
Apr 4 '07 #4
mrhoo
428 Contributor
Expand|Select|Wrap|Line Numbers
  1. function rowNumber(who){
  2.     while(who.nodeName!='TR')who=who.parentNode;
  3.     if(!who)return false; // not in a row
  4.     var pa=who.parentNode;
  5.     while(pa.nodeName!='TABLE')pa=pa.parentNode;
  6.     var A=pa.getElementsByTagName('TR');
  7.     var i=0;
  8.     while(A[i]){
  9.         if(A[i]==who)return i;
  10.         ++i;
  11.     }
  12.     return false;
  13. }
Apr 4 '07 #5
maxing80
1 New Member
[HTML]<tr><td>11 row<input type="button" value="detecta index" onclick="alert( this.parentNode .parentNode.row Index)"></td></tr>[/HTML]
Apr 4 '07 #6

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

Similar topics

1
1528
by: Doron | last post by:
is there a setting that will ebnable uniform extent allocation upon creation of index/table by default ? if there isn't any default setting can you code it in? thanks, Doron
5
4377
by: Tompa | last post by:
Hi, I would like to create images on the fly as a response to an http request. I can do this with PIL like this (file create_gif.py): from PIL import Image, ImageDraw print 'Status: 200 OK' print 'Content-type: text/html' print print '<HTML><HEAD><TITLE>Python Dynamic Image Creation Test</TITLE></HEAD>'
10
26076
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not null references another, FK_LASTLYOID bigint not null references lastly, unique (FK_OTHEROID,FK_ANOTHEROID))
4
2407
by: Chris via AccessMonster.com | last post by:
I have the challenge of needing to automate table creation. It doesn't end there the tables have to be created from one table that looks something like this... Email Source at@at.com EB no@no.com EN in@in.com EB at@at.com EN ...
1
2130
by: andrew queisser | last post by:
I've been trying to dynamically create a class DevT that's derived from a generic base GenBase<T>. It doesn't seem to work. I'm attaching a code sample below that illustrates the problem. CreateType() fails when the base class is a parametrized class, as in DevT : GenBase<int>. CreateType() works if the base class is not parametrized, even...
2
16237
by: charliewest | last post by:
I need to create textboxes in real-time, the actual number of which is determine by a result from a database query. I have been able to create the controls, and then add them to the ASPX page. However, when i submit the page, i am unable to read the values entered in these new textboxes. I have first tried to use ...
3
2467
by: steve | last post by:
Hello, I am having a problem with an index controlled partitioned table. I was altering a table using SQL. I was trying to add a partition to a table to change it from index controlled to table controlled. This is a new feature in version 8. Version 8 will automatically switch the table from index controlled to table controlled if you...
8
23361
by: william_dean | last post by:
Hello, I've done some searching around the post, and I have found quite a bit of information related to the setAttribute and it's related uses. My problem lies in the usage of colspanning in dynamic table creation. Code Snippet <SCRIPT LANGUAGE="JavaScript"> function morecase(id){ var tbody =...
1
20540
by: None | last post by:
Dynamic array creation Hi all... here's a good one for you... I have a situation where I have some bean, and I need to populate an array field in it... here's the problem... I do not know the element type of the array before runtime. Now, I've been planning on using Commons Beanutils, since the rest of this particular app does (it's...
3
2088
by: arunank | last post by:
Hi, The following code for dynamic table creation is not working. Can anyone please help me. The dynamically created rows and columns are not getting populated. CODE: ========= <html>
0
7693
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...
0
7605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
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. ...
1
7665
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...
0
7962
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...
1
5501
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...
0
3651
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...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
933
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...

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.