• 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

dynamically add rows to the exitsting table

 
Greenhorn
Posts: 29
Netbeans IDE Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have the table with 100 records
at the first time the page loading i want to display only 10 records and the more link
if the link is clicked display 10 more records

the records are populated from the oracle database

i don't know how to use the oracle contents in javascript or ajax
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ajax call makes call to the backend, backend grabs the next set of rows. The rows are returned. The callback function adds the rows to the table.

Eric
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understand well, you want to display 10 more records each time you click i.e. if you had 20 records and click, 10 records should append to the existing.


So this you can do it through innerHtml (on client side) i.e. you take the codes which are between your <table> tag and add the code replied by the server(responseText).

What I mean is this: Populate a string of the records which you want to add on server side. This string should contain your <tr><td><input type=text id="newCount" value="hereYouMakeTheServerWriteTheDataYouQueried">...

(Also include name and id attribute if you have to use it on client side)
Loop 10 times and make your string variable append each new record.
After looping, you should get a string which contains all your tags for the rows, the textboxes,value in the textboxes etc.

Then you make the server send this string. When the client receives this string(responseText), you use JS to append the server's reply with the existing code.

Make sure that your table is within a div.

If you don't understand AJAX, this won't be easy to explain you all the steps.



............

There's another alternative to AJAX which is not so nice(because it will require refreshing your page):

Store in a session the number of records.

Make your client request 10 new records:

1) Use the div tag to hide your text box, form. Set your text box value to 10 by default.
2) When you click, a request is sent and the server reads the value in the session.
3)You add this value to 10.Then you return to your page(refresh), read the new session value and Loop this number of times to populate your table.

AJAX is worth learning...
 
Greenhorn
Posts: 11
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

satheesh subramani wrote:i don't know how to use the oracle contents in javascript or ajax


I think your question is more about how to make an oracle/sql query from javascript. I doubt that one can actually do that, As far as I know you will need to do something on the server side to call that.. like, JAVA to fetch the records from the database.

Once you get them, you can pass them as is to the client side and wrap into a table-row code and add to the existing table, or as suggested by Charles can also pass the formed string from the server and append to the table.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic