473,382 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Dynamic table creation - table row index

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.getElementById("t1");
var newTr = document.createElement("TR");
var newTd1 = document.createElement("TD");
var ss=document.getElementById("task1").innerHTML;
newTd1.innerHTML = document.getElementById("task1").innerHTML;
newTd1.setAttribute("align","center");
var newTd2 = document.createElement("TD");
newTd2.innerHTML = document.getElementById("activity1").innerHTML;
newTd2.setAttribute("align","center");
newTr.appendChild(newTd1);
newTr.appendChild(newTd2);
tbody.appendChild(newTr); }


span id="task1" style="visibility:hidden" property="task1">

<html:select styleId="tasks" property="tasks" onchange="hi('loadactivities.do?taks=' + this.value);createRow();">

<option value="All">----</option>
<bean:define id="hoursCollection" name="loginForm" property="task" />
<logic:present name="hoursCollection">
<logic:iterate id="hour" name="hoursCollection">
<html:option value="<%=(String)hour%>"><%=(String)hour%></html:option>
</logic:iterate>
</logic:present>
</html:select>
</span>
<span id="activity1" style="visibility:hidden">
<html:select styleId="activitys" property="activitys" >
<option value="All">----</option>

<bean:define id="activityCollection" name="loginForm" property="subtasks" />
<logic:present name="activityCollection">
<logic:iterate id="hour" name="activityCollection">
<html:option value="<%=(String)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..whereever 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 10505
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
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
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="getindex(this)";

function getindex(tbody){
alert(tbody.parentNode.rowIndex);
}

Its coming as undefined..Can u please help
Apr 4 '07 #4
mrhoo
428 256MB
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
[HTML]<tr><td>11 row<input type="button" value="detecta index" onclick="alert(this.parentNode.parentNode.rowIndex )"></td></tr>[/HTML]
Apr 4 '07 #6

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

Similar topics

1
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
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'...
10
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...
4
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 ...
1
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. ...
2
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....
3
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...
8
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...
1
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...
3
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>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.