By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

string to object

P: n/a
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/...8d4af98135fa07

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?emp loyee={employeeUsername}&timestamp={timestamp}&hou rsId={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>

Nov 24 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
VK

Lee wrote:
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).

Nov 24 '06 #2

P: n/a
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.

Nov 26 '06 #3

P: n/a
VK

Lee wrote:
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.

Nov 26 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.