• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

To create Table dynamically inside DIV tag using ajax responseXML

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Respected members
I'm trying to do like this
1. I have a div msgDiv tag in which i have a table msgTab, that should display list of messages..currently table is empty
2. When i'll get a responseXML ,then the data in that response should be displayed in the table as links, which ,on onclick method should display method in textarea msgText.Something similar to outlook or latest yahoo mail.

so my problem is how to create table of links inside div tag at runtime when xml response is received. The data in <td> needs to be filled with values in xml response for n no. of lines

<div id="msgDiv" style="overflow:auto; width:1202px; height: 160px;" align="left">
<table id="msgTab" width="1202" border="1">
<tr>
<th width="40" height="30" bgcolor="#003399" class="style1 style3" scope="col">No.</th>
<th width="130" height="30" bgcolor="#003399" class="style1 style3" scope="col">Message type</th>
<th width="169" bgcolor="#003399" class="style1 style3" scope="col">Date and Time</th>
<th width="200" bgcolor="#003399" class="style1 style3" scope="col">From</th>
<th width="506" bgcolor="#003399" class="style1 style3" scope="col">Subject</th>
</tr>
<tr>
<td> </td>
<td> </td>
<th> </th>
<td> </td>
<td> </td>
</tr>
</table>
</div>



Thanks
nilesh
 
Sheriff
Posts: 67590
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
You'll need to traverse the XML to get the data, then create DOM elements to represent the corresponding table.

Sounds like a nightmare to me. Any reason you can't pre-format the table using JSP on the server to create an HTML fragment that's returned in responseText that you can simply add to the DOM? Much simpler.
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1:the format of your XML file is important
2: it's really easy to solve

it's better change your table as this


and lets to start with core
Ok I don't know what is the Format of your XML file but by the an Example
Alright imagine this is my XML format




OK let's to make core(javascript file)
NOTE:All of the solutions are my suggestions maybe we have better way


1:after get the XML from server store it in somewhere (such as a global variable)
2:parse XML and create elements and add it on table(bodySection)

so check this sample
client send a request to server then parse it, after that add it to table



I hope you understand what i said with jagy English
Alright put them together(a template)
 
nilesh beit
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear ArAsh Dex
Thank you very very much for your code. I'll study and try to implement that code for responsXML.

Dear Bear Bibeault
Thanks a lot for showing another way that didn't strike my mind.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic