473,320 Members | 1,978 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,320 software developers and data experts.

how to dynamically add a row for each click on a link

hi all..
Im new to DHTMl,Javascript

I have 4 rows each with a dropdownlist,textfield.I have a link.When the user clicks a link first time.i show one row now based what i select in the dropdownlist i want to show the corresponding row...now my issue is how can i change the position of where the row should appear.say in html i have rows of id1 ,id2,id3.By default it would show in the same order is it possible to change the place where it is displayed .that is can i dynamically display a row in the first line the 1st time & make it display it in another line next time based on the values..


I have been trying to do this.I need it ver badly..If someone could help it would be really great

Thanks in Advance
Feb 8 '08 #1
6 1860
dlite922
1,584 Expert 1GB
hi all..
Im new to DHTMl,Javascript

I have 4 rows each with a dropdownlist,textfield.I have a link.When the user clicks a link first time.i show one row now based what i select in the dropdownlist i want to show the corresponding row...now my issue is how can i change the position of where the row should appear.say in html i have rows of id1 ,id2,id3.By default it would show in the same order is it possible to change the place where it is displayed .that is can i dynamically display a row in the first line the 1st time & make it display it in another line next time based on the values..


I have been trying to do this.I need it ver badly..If someone could help it would be really great

Thanks in Advance
i have a difficulty understanding what you're trying to do. All i know is that you have 4 rows and they should be displayed dynamically. the rest is blurry.

Please re explain or provide some code.
Feb 8 '08 #2
gits
5,390 Expert Mod 4TB
hi ...

may be the following simple example is of help to you. i think you want to add the rows to a table in the same order as the options in a select-element are selected? otherwise explain your problem in more detail and/or post the code you already have.

[HTML]<html>
<head>
<script type="text/javascript">
var opts_rows = {};

function create_lines() {
var opts = document.getElementById('my_options');

for (var i = 0, opt; opt = opts[i]; i++) {
var row = document.createElement('td');
row.innerHTML = '<td>row for option: ' + opt.value + '</td>';

opts_rows[opt.value] = row;
}
}

function add_line(node) {
var cnt = document.getElementById('my_table');
var tgt = cnt.getElementsByTagName('tbody')[0];

tgt.appendChild(opts_rows[node.value]);
}
</script>
</head>
<body onload="create_lines();">
<select id="my_options" onchange="add_line(this);">
<option value="0">select an option</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
<table id="my_table"><tbody></tbody></table>
</body>
</html>
[/HTML]
kind regards
Feb 8 '08 #3
Hi,
I have a row with a dropdownlist and textfield .
now i have a link called 'add'.
I would like to know how to add a row dynamically for each click on the link using jsp & javascript.
In short each time i click add link i want a row with dropdownlist and textfield.
and also these values have to be set in the formbean.

I have no idea how to do add a row dynamically & also set it to the formbean dynamucally.It would be really great if someone could provide me with a sample code with a simple example.

Thanks in Advance
Feb 11 '08 #4
hsriat
1,654 Expert 1GB
see this example...

http://www.w3schools.com/js/tryit.as...able_insertrow
Feb 11 '08 #5
acoder
16,027 Expert Mod 8TB
I've merged the two threads because they seem to relate to the same problem. Please keep it to one thread. Thanks!
Feb 11 '08 #6
thanks for the example help is much appreciated .
Feb 11 '08 #7

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

Similar topics

5
by: john_williams_800 | last post by:
Hi; I am just starting to use the DOM to do some more advanced javascripting so please be patient with my question if it is an ignorant question. I would like to use the DOM to dynamically...
8
by: simon | last post by:
On code behind file: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then Dim ctrl As New LinkButton ctrl.ID =...
7
by: who be dat? | last post by:
I need some help here. I'm creating a list on a page where the list is created from a dataset with two tables linked with a datarelation. The first table is a list of groups while the second...
2
by: jmarendo | last post by:
Hello, After reading through the "Table Basics - DOM - Refer to table cells" example at mredkj.com , I modified the code for my own purposes. In the modified version, I create a hyperlink and...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
5
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
Hi, I have a strange issue occurring with LinkButtons that are dynamically added to each (data) row of my DataGrid on that grid's ItemDataBound event. Each LinkButton is assigned its own event...
13
by: Konrad Hammerer | last post by:
Hi! Can somebody tell me or show me an example how to add a textbox and a button dynamically by code to an apsx page and how to read the filled in value from the textbox after the user has...
0
by: Syoam4ka | last post by:
My project is about jewellery. I have devided my jewelery into main types, which each one of them has sub types, and each one those sub types has the jewellery. I have a tabcontainer. It includes...
3
by: Allen Chen [MSFT] | last post by:
Hi Richard, Quote from Richard================================================== However I also want to be able to remove the panes. I have tried to include this, but find that when I first...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
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
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.