• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Addressing dynamic table elements

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an application in which i am retreiving data from database using AJAX(i.e i am using javascript in my jsp page and forwarding the onclick request to a servlet) and a XML is send from the servlet to the jsp page.. i dont know how to extract the XML file and put the contents of the database inside a table row... please somebody explain how to do it...

i m new to AJAX..
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AJAX is handled in the HTML / JavaScript forum. Moving there.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you googled JavaScript parse XML

Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please avoid posting in all uppercase, thanks.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have a choice of interchange format, you might want to consider using JSON over XML. It's a lot easier to deal with in the script code.
 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
even if i use JSON, i have to retrieve the data through DOM.. but how to put the data inside a dynamically created table..? even through JSON i can put the data only in elements of the HTML page... but i want the data to be displayed inside a table.. how to do that..?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My point was that retrieving the data as JSON is a lot easier than digesting an XML construct.

kunal vermaa wrote:how to put the data inside a dynamically created table..?


The same way that you'd add it to any other part of the DOM.

even through JSON i can put the data only in elements of the HTML page


No, you can put them anywhere you want.

but i want the data to be displayed inside a table.. how to do that..?


Again, same way as anywhere else. Tables are DOM elements just like any other HTML elements.
 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok.. i didnt know that.. but we can access Html elements through element ID.. something like this..



then how can i access a table and put value in each row or column....? please explain.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you not think that you can use id values with tables?
 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I havnt used id value for a table.. can you show me how its done..?? and I want to create dynamic table rows... so how i would know the id values of tables..?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you are creating the element, you can give them any id that you like. So it should be easy for you to know what the id values are since you will create them.

 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nobody in the javaranch have a solution for my problem...? i am very confused ..please help..
 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok.. but i want the table rows to be created dynamically.. so how can i put id in them.. and can you please give an example of how to put different id for different table rows..
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That greatly depends on how you are creating the elements. If you don't know how to add attributes like id to the elements you are creating, that's the next thing to learn.

By the way, posts like:

nobody in the javaranch have a solution for my problem...?



when someone has been trying to help you are just going to tick people off. Ticked off people don't feel much like helping.
 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am sorry for making anybody feel that way.. please accept my apologies..
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you create the element, simply assign an id value to it that you can use later.

You might also want to consider using a library like jQuery that makes it easy to select element by criteria other than id. (and also makes it easier to create elements on-the-fly in the first place.)
 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that means to say that for a table only 1 id can exist..? can you tell me a better method for displaying information on as jsp page row by row..?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kunal vermaa wrote:that means to say that for a table only 1 id can exist..?


Huh?

Every id needs to be unique. That has nothing to do with tables, but applies to all elements.

It might help if you explained the structure of the table and your needs for addressing it later.

It might be as simple as adding ids like "row1", "row2", "row3"...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic