L
Lee
Hi, I have a template file that looks something like this
<tr>
<td>{var1}</td>
<td>{var2}</td>
<td>
<table>
<tr>
<td>Name: {name3}</td>
<td>Age: {age3}</td>
</tr>
</table>
</td>
</tr>
And I have a small javascript function that opens the template file
above, replaces the variables with values in a hash, and returns the
html in a string. Then, I put it into a table as a new row by just
adding it to the tbody string.
Works beautifully... in Firefox. In other browsers like IE 6, I think
I need to use functions like table.addrow() and table.addcell(). These
functions are compatible with other new browsers as far as I know and
so this would be what I want to use.
My question is, how would I do this if I want to start with the
template file? The reason I want a template like this is that I also
have server side scripts using it, and I figure it's the best way for
javascript and php to use a template from the same source.
I was thinking of parsing it using regex, finding each row and adding
it individually, but I am not sure what the regex would be to find each
individual row. And I am not sure if I can simply add a table without
a function similar to table.addrow().
Any help would be appreciated.
<tr>
<td>{var1}</td>
<td>{var2}</td>
<td>
<table>
<tr>
<td>Name: {name3}</td>
<td>Age: {age3}</td>
</tr>
</table>
</td>
</tr>
And I have a small javascript function that opens the template file
above, replaces the variables with values in a hash, and returns the
html in a string. Then, I put it into a table as a new row by just
adding it to the tbody string.
Works beautifully... in Firefox. In other browsers like IE 6, I think
I need to use functions like table.addrow() and table.addcell(). These
functions are compatible with other new browsers as far as I know and
so this would be what I want to use.
My question is, how would I do this if I want to start with the
template file? The reason I want a template like this is that I also
have server side scripts using it, and I figure it's the best way for
javascript and php to use a template from the same source.
I was thinking of parsing it using regex, finding each row and adding
it individually, but I am not sure what the regex would be to find each
individual row. And I am not sure if I can simply add a table without
a function similar to table.addrow().
Any help would be appreciated.