March 26, 200322 yr 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
March 26, 200322 yr 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
March 26, 200322 yr Author thanx Garry! p.s. Didn't want to "bother you directly" that's why the topic is as it is! thanx
March 26, 200322 yr Author I forgot that <script> can be stuck driectly into the body of html....we get spoiled by WYSIWYG editors. Thanx again
March 26, 200322 yr 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
March 26, 200322 yr Author 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
March 26, 200322 yr Author 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
Create an account or sign in to comment