Leb i Sol Posted March 26, 2003 Share Posted March 26, 2003 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 More sharing options...
Garry Claridge Posted March 26, 2003 Share Posted March 26, 2003 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 More sharing options...
Leb i Sol Posted March 26, 2003 Author Share Posted March 26, 2003 thanx Garry! p.s. Didn't want to "bother you directly" that's why the topic is as it is! thanx Link to comment Share on other sites More sharing options...
Leb i Sol Posted March 26, 2003 Author Share Posted March 26, 2003 I forgot that <script> can be stuck driectly into the body of html....we get spoiled by WYSIWYG editors. Thanx again Link to comment Share on other sites More sharing options...
Anatoli Posted March 26, 2003 Share Posted March 26, 2003 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 Link to comment Share on other sites More sharing options...
Leb i Sol Posted March 26, 2003 Author Share Posted March 26, 2003 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 More sharing options...
Leb i Sol Posted March 26, 2003 Author Share Posted March 26, 2003 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now