473,626 Members | 3,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

7 New Member
hi all..
Im new to DHTMl,Javascrip t

I have 4 rows each with a dropdownlist,te xtfield.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 1874
dlite922
1,584 Recognized Expert Top Contributor
hi all..
Im new to DHTMl,Javascrip t

I have 4 rows each with a dropdownlist,te xtfield.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 Recognized Expert Moderator Expert
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.getEle mentById('my_op tions');

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

opts_rows[opt.value] = row;
}
}

function add_line(node) {
var cnt = document.getEle mentById('my_ta ble');
var tgt = cnt.getElements ByTagName('tbod y')[0];

tgt.appendChild (opts_rows[node.value]);
}
</script>
</head>
<body onload="create_ lines();">
<select id="my_options " onchange="add_l ine(this);">
<option value="0">selec t an option</option>
<option value="1">optio n 1</option>
<option value="2">optio n 2</option>
<option value="3">optio n 3</option>
</select>
<table id="my_table">< tbody></tbody></table>
</body>
</html>
[/HTML]
kind regards
Feb 8 '08 #3
prathna
7 New Member
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 Recognized Expert Top Contributor
see this example...

http://www.w3schools.com/js/tryit.as...able_insertrow
Feb 11 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
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
prathna
7 New Member
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
4887
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 create an html table via javascript. While that table is being dynamically created in a javascript function I would like to dynamically insert text and a hyperlink with an image into each cell.
8
10787
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 = "link1" ctrl.Text = "link create" ctrl.CommandArgument = "myargument"
7
2074
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 table is a list of items in that group. I want to show these items in what would basically look a lot like a tree view. I decided to just show everything in a placeholder control on an aspx form. First, I display a groupname from the first table...
2
3378
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 place it in the last cell of each row that I create dynamically using DOM methods. Everything is working well (that is, just like the original example) except for something related to the function behind my link. The link simply calls a function...
5
6754
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 link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
5
4706
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 handler to deal with the Command event, but for some reason I can get this to work in a C# project but not in a newly created VB.NET one. The relevant VB.NET is as follows:
13
1517
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 clicked the button? I have tried this without success because after the user has clicked the button, the textbox seems to be disappeard! I have added it to a placeholder and tried to read it with ctype(placeholder1.controls.item(0),textbox).text,...
0
1368
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 tabpanels such as:Catalog,Terms,SiteMap.ViewCart ,etc. All the jewellery Intro is in the Catalog panel. when I first click the Catalog panel it Introduces me all the main types of the jewellery(It's all done dynamically from the cs file).The...
3
5258
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 add the pane the remove event does not get handled, though thereafter it is handled without problems. ==================================================
0
8266
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8705
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...
0
8638
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8365
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
8505
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...
1
6125
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
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
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.