Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

document.write(" MEGA HTML");


Leb i Sol

This topic is 7865 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello people!

I was wondering if anyone has knowledge/experience on how browsers digest A LOT OF lines of JavaScript. I am forced ( I think) to use it but I would like to decorate it with HTML.So my page goes something like this:

-------------------------------------

<body>

<script>

document.write("<table width="100%" height="496" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="#666666" id="MAINTABLE">");

document.write("<tr>");

document.write("<td align="center" valign="middle"> ");

document.write("<table width="99%" height="494" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" id="INSIDETABLE">");

document.write("<tr>");

document.write("<td width="40%" height="25"><hr size="1" color="#666666"> </td>");

document.write("<td width="20%" height="25" align="center" class="maskL">ALL REPORTS</td>");

document.write("<td width="40%" height="25"><hr size="1" color="#666666"> </td>");

document.write("</tr>");

........ ETC.

---------------------------

so I was wondering about the speed of all this or an alternative solution!

thanx

Link to comment
Share on other sites

You could use tables like this:

<body>

<table .... >

<script>var tot_qty = 0; var loc_total; var curr_loc = "<b>Location</b>";

[FMP-Record]

if (curr_loc == "[FMP-Field:locations::location_name]")

    {

       loc_total += [FMP-Field:qty];

    tot_qty += [FMP-Field:qty]; }

else

    {

    document.write("<tr><td>" + curr_loc + "</td><td>|</td><td>" + loc_total + "</td></tr>");

    curr_loc = "[FMP-Field:locations::location_name]";

    loc_total = [FMP-Field:qty];

    tot_qty += [FMP-Field:qty];

    } ;           

[/FMP-Record]

document.write("<tr><td>" + curr_loc + "</td><td>|</td><td>" + loc_total + "</td></tr>");

document.write("<tr><td colspan='3'>Total Quantity: " + tot_qty + "</td></tr>");</script>

</table>

</body>

However, any speed differences would be tiny.

All the best.

Garry

Link to comment
Share on other sites

I did use once quite lot "document.write" with many conditions and no one spot the difference in rendering.

It was the only way to do really complicated things with WC page e.g. variable size of fields depending on size of monitor.

First my reaction was "impossible with CDML", but I did managed with JS. Then I got cold shower from boss, that I am negative, bla, bla smile.gif

Link to comment
Share on other sites

hey Garry!

quick question on Java Script:

this part in particular:

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

else {

document.write("<tr><td>" + curr_loc + "</td><td>|</td><td>" + loc_total + "</td></tr>");

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

It will ALWAYS display default values (curr_loc and loc_total)of variables that are "0" zero as declared on top. So the output is always:

Location | 0

Location1| X

Location2| xx

....

is there a way to get rid of the first line that is generated OR better yet tweak it so it shows text of my choice

Link to comment
Share on other sites

Garry's:

Use this:

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

else {

if (curr_loc != "") { document.write("<tr><td>" + curr_loc + "</td><td>|</td><td>" + loc_total + "</td></tr>"); } ;

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

Initialise curr_loc as "".

You can add a row before the script starts:

<tr><td><b>Location</b></td><td><b>Qty</b></td><td><b>Sales</b></td></tr>

Hope this helps.

Garry

Link to comment
Share on other sites

This topic is 7865 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.