string to object

L

Lee

Hi, how would I change this to an object that I can add onto a table?
And how would I add it to the table?

<tr>
<td>{var1}</td>
<td>{var2}</td>

<td>
<table>
<tr>
<td>Name: {name3}</td>
<td>Age: {age3}</td>
</tr>
</table>
</td>

</tr>

I was talking about it in this discussion but the topic got cold
somehow.
http://groups-beta.google.com/group/comp.lang.javascript/browse_thread/thread/d28d4af98135fa07

Actually, this is the actual string, but the top one is easier to look
at.

<tr id='schedule_row{hoursId}' class='schedule_row'>
<td class='icon_schedule {dayType}' id='icons{hoursId}'><a
href='javascript:popUpWindow("editschedule.php?employee={employeeUsername}&timestamp={timestamp}&hoursId={hoursId}",0,0,600,600);'><img
src='images/pen.gif' class='icon' style='height:10px;' /></a><a
href='javascript:deleteHoursRow("{hoursId}");'
style='text-decoration:none'>X</a></td>

<td class='name {dayType}' id='name{hoursId}'
onclick="makeCalendarInputField(this,'{hoursId}','name');"
onkeyup="blurThis(this,event);">{name}</td><td class='time'
id='hours{hoursId}'>

<table border=0 id='start{hoursId}' onMouseOver='showControls(this);'
onMouseOut='hideControls(this);' class='{dayType}' cellspacing=0
cellpadding=0>
<tr>

<td valign='top' id='start0_{hoursId}' class='start0'
onclick='makeCalendarInputField(this,"{hoursId}","start");'
onkeyup='blurThis(this,event);'>{start}</td>

<td>
<table id='start{hoursId}_controls' class='hoursControls'
cellspacing=0 cellpadding=0>

<tr>
<td><a href='javascript:void(0);'
onClick="ajaxChangeHour('1','{hoursId}','start');"><img
src='images/up.gif' class='icon controlsIcon' /></a></td>
</tr>
<tr>
<td><a href='javascript:void(0);'
onClick="ajaxChangeHour('-1','{hoursId}','start');"><img
src='images/down.gif' class='icon controlsIcon' /></a></td>
</tr>
</table>
</td>
</tr>

</table>
</td>
<td class='{dayType}'> - </td>
<td>
<table id='end{hoursId}' onMouseOver='showControls(this);'
onMouseOut='hideControls(this);' class='{dayType}' cellspacing=0
cellpadding=0>
<tr>
<td valign='top' id='end0_{hoursId}' class='end0'
onclick='makeCalendarInputField(this,"{hoursId}","end");'
onkeyup='blurThis(this,event);'>{end}</td>

<td>
<table id='end{hoursId}_controls' class='hoursControls'
cellspacing=0 cellpadding=0>
<tr>
<td><a href='javascript:void(0);'
onClick="ajaxChangeHour('1','{hoursId}','end');"><img
src='images/up.gif' class='icon controlsIcon' /></a></td>
</tr>
<tr>
<td><a href='javascript:void(0);'
onClick="ajaxChangeHour('-1','{hoursId}','end');"><img
src='images/down.gif' class='icon controlsIcon' /></a></td>
</tr>
</table>

</td>
</tr>
</table>
</td>
</tr>
 
V

VK

Lee said:
Hi, how would I change this to an object that I can add onto a table?
And how would I add it to the table?

<tr>
<td>{var1}</td>
<td>{var2}</td>

<td>
<table>
<tr>
<td>Name: {name3}</td>
<td>Age: {age3}</td>
</tr>
</table>
</td>

</tr>

I was talking about it in this discussion but the topic got cold
somehow.
<http://groups-beta.google.com/group/comp.lang.javascript/browse_thread/thread/d28d4af98135fa07>

What's wrong with the advises you've got in the previous thread? IMHO
they provided enough of possible directions to change your solution.
The background is that you cannot do exactly what you want in the exact
way you want: Table DOM handling requires a strict hierarchy: you
create table; you create tbody; you create TR; you fill TR with TD
elements; you add TR to tbody; you repeat for each row. You cannot just
drop random HTML blocks into table here and there: it will not work or
it will crash somewhen later. Respectively you cannot just take a
source code for a TR (with all TD's code in it) and somehow transform
it into into TR object in one move. If you insist on the current
approach then you need a throughout source parsing: when it would be
more easy and effective to use XSLT (with your HTML template kept as a
well-formed XML document).
 
L

Lee

I was hoping that someone would have a creative idea on how to use the
given template. I know that I have to use the table functions instead
of inserting html. I just want to know if there is a creative way to
do this.
 
V

VK

Lee said:
I was hoping that someone would have a creative idea on how to use the
given template. I know that I have to use the table functions instead
of inserting html. I just want to know if there is a creative way to
do this.

Well, a creative (plus standard and effective) way could be by using
the HTML source as XSL template, actual data as XML source and so make
an XSLT transformer producing (server-side or client-side by your
choice) a ready to use HTML page. Besides other things it also
eliminates 100% script-dependency of the front display.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top