473,626 Members | 3,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

html table dynamic dimensions that track a for loop

After a few searches & inquiries here, I have a method of generating an
html table populated with results of equations that works and wasn't
too far up a learning curve for me, thanks to a helpful
respondent/poster here...

<script type="text/javascript">
var AAA = new Array(4)

AAA[0] = 2*0.1*Math.roun d(10*Math.log(3 2)/Math.log(2))
AAA[1] = 2*0.1*Math.roun d(10*Math.log(1 6)/Math.log(2))
AAA[2] = 2*0.1*Math.roun d(10*Math.log(8 )/Math.log(2))
AAA[3] = 2*0.1*Math.roun d(10*Math.log(5 .656)/Math.log(2))
theTable='<tabl e border="5"><tr> <td>';
theTable+=AAA[0];
theTable+='</td><td>';
theTable+=AAA[1];
theTable+='</td></tr><tr><td>';
theTable+=AAA[2];
theTable+='</td><td>';
theTable+=AAA[3];
theTable+='</td></tr></table>';
document.write( theTable);

</script>
This is a fixed length example. In use, one selects a variable that
determines how many results are generated, using a for-loop, choosing
the range and a couple choices of increment (1, 1/2, 1/3).

Are there any implicit reasons why the array above could not be made
dynamic to track the for loop variable?

I did some searching first as is always recommended, but that seems to
be a never-ending chase for the right words to use in a question...I
DID look, but am apparently searching for the wrong keywords.

Thanks

Murray

Nov 23 '05 #1
7 1864
murrayatuptowng allery wrote:
After a few searches & inquiries here, I have a method of generating an
html table populated with results of equations that works and wasn't
too far up a learning curve for me, thanks to a helpful
respondent/poster here...
Why don't you continue the thread you are referring to? I, for
one, don't know what particular poster you are referring to.
var AAA = new Array(4)
In JS/ECMAScript, arrays, as any objects, are dynamic by default, you don't
have to specify the number of elements you wish to store in it. Thanks to
Murphy's Law, depending on the implementation, the above could make you end
up with an array that has only one element (that is later overwritten
anyway) with the number value 4.
AAA[0] = 2*0.1*Math.roun d(10*Math.log(3 2)/Math.log(2))
AAA[1] = 2*0.1*Math.roun d(10*Math.log(1 6)/Math.log(2))
AAA[2] = 2*0.1*Math.roun d(10*Math.log(8 )/Math.log(2))
AAA[3] = 2*0.1*Math.roun d(10*Math.log(5 .656)/Math.log(2))
Why not

AAA = new Array(
0.2*Math.round( 10*Math.log(32)/Math.log(2)),
0.2*Math.round( 10*Math.log(16)/Math.log(2)),
0.2*Math.round( 10*Math.log(8)/Math.log(2)),
0.2*Math.round( 10*Math.log(5.6 56)/Math.log(2)));

?

Why computed values anyway?
theTable='<tabl e border="5"><tr> <td>';
theTable+=AAA[0];
theTable+='</td><td>';
theTable+=AAA[1];
theTable+='</td></tr><tr><td>';
theTable+=AAA[2];
theTable+='</td><td>';
theTable+=AAA[3];
theTable+='</td></tr></table>';
Do you really understand how many String objects are created in the process?
document.write( theTable);
document.write( new Array(
'<table border="5"><tr> <td>',
AAA[0],
'</td><td>',
AAA[1],
'</td></tr><tr><td>',
AAA[2],
'</td><td>',
AAA[3],
'</td></tr></table>').join(" "));

BTW, I prefer the Array literal syntax: `[element1, element2, ...]'.
</script>

This is a fixed length example. In use, one selects a variable that
determines how many results are generated, using a for-loop, choosing
the range and a couple choices of increment (1, 1/2, 1/3).
So you should post the _used_ code.
<http://jibbering.com/faq/>
Are there any implicit reasons why the array above could not be made
dynamic to track the for loop variable?


No, unless the language implementation is really very b0rken.
PointedEars
Nov 23 '05 #2
Thomas 'PointedEars' Lahn wrote:
murrayatuptowng allery wrote:
var AAA = new Array(4)


In JS/ECMAScript, arrays, as any objects, are dynamic by default, [...]


I should have written "_core_ objects". Host objects are
allowed to be static. However, Array is a core object.
PointedEars
Nov 23 '05 #3
Well, P-E, you have helped me in that past. Thank you again. I don't
remember who helped me with what or even what solutions I mimicked.
This project has been traveling around in a backpack waitign for spare
time & often gets shelved for other priorities.

The complete code does not yet exist. I am tackling each feature one at
a time and usually spin off an analogous fragment that is less messy to
learn a technique. If it works, I continue the messy part along the
lines of the solution. Sometimes I can't figure it out and compromise
with something simpler. Probably not vey elegant logic, but I feel
safer adhering to deprecated or near-deprecated methods so I don't use
something that only works with certain browsers. The above statement
doesn't guarantee anything, but it's just a guide.

This whole thing is much messier than I allude to. One might recommend
I do it a different way. I don't need to prove I can write canonical
efficient code. This is survival-skill coding. It's one of those
projects that people will question why bother? Just something I want to
do. Keeps me off the street, as it were.

The reason for calculated content is the whole application is an
application-specific calculator. User enters some parameters, script
determines some basic subsequent results then generates a table of raw
numbers plus, if desired, extrapolated, corrected and curve-fitted data
based on a couple different accepted models, also choices selected
initially. The correction terms are 3rd-order polynomials stored in
another set of arrays.

The whole thing is alot simpler in a spreadsheet, but the people I
intend to share this with will probably only evaluate it if it is
nearly completely automated other than some radio buttons, drop-downs
etc.

The inelegant method of leaving the equations unsimplified reminds me
which equations had an exponent 'brought down as a multiplier' as
properties of logarithmic manipulation.

BTW, to give you some perspective for the prehistoric approach to my
coding, the last programming class I had was punch-card Fortran,
preceded by time-share-computer BASIC using an acoustic telephone modem
(I'm not counting a couple microprocessor classes). Someday I'll take a
C class or learn it on my own...some...da y...

That's why some of the pre-searching and latest-accepted-methology
recommendations drown me in additional parallel learning curves.

I looked at the jibbering faq to try and pick up on what etiquette I
may have breached (that seemed to be your implication), but there's
more stuff in there than I can assimilate in one visit.

OT (again), I need to figure out how to log in here without my naked
email address because it just advertises 'open season' for spam. I get
piles of it shortly after each post.

Thanks again

Murray

Nov 23 '05 #4
murrayatuptowng allery wrote:
Well, P-E, you have helped me in that past. Thank you again.
You're welcome.
I don't remember who helped me with what or even what solutions I
mimicked.
ACK
This project has been traveling around in a backpack waitign for spare
time & often gets shelved for other priorities.

The complete code does not yet exist.
Does not matter, the relevant snippet will/would have suffice(d).
I am tackling each feature one at a time and usually spin off an analogous
fragment that is less messy to learn a technique. If it works, I continue
the messy part along the lines of the solution. Sometimes I can't figure
it out and compromise with something simpler. Probably not vey elegant
logic, but I feel safer adhering to deprecated or near-deprecated methods
so I don't use something that only works with certain browsers. The above
statement doesn't guarantee anything, but it's just a guide.
However, if you expect to produce viable code, looking into documentation
like language references and specifications is a must. Fantasy code will
not get you very far, it seldom works and almost always breaks.
This is survival-skill coding. It's one of those projects that people will
question why bother? Just something I want to do. Keeps me off the street,
as it were.
I understand completely, I am in the same position regarding other
languages.
The inelegant method of leaving the equations unsimplified reminds me
which equations had an exponent 'brought down as a multiplier' as
properties of logarithmic manipulation.
You should be aware that this increases calculation time which is
probably not desired. Probably a decent comment will do instead.
BTW, to give you some perspective for the prehistoric approach to my
coding, the last programming class I had was punch-card Fortran,
preceded by time-share-computer BASIC using an acoustic telephone modem
(I'm not counting a couple microprocessor classes). Someday I'll take a
C class or learn it on my own...some...da y...
You know, I have developed only a basic understanding of C(++) and almost
no practical experience in it yet. Came from a BASIC dialect on GDR's Z80
clone (called KC 85/3[1]), which saved programs on audio tapes(!), to Turbo
Pascal to Delphi (and a little bit C[++]), had a short-lived professional
relationship with VBA, then moved on to Web development, including
JS/ECMAScript, and to other languages like (ba)sh and Tcl/expect, which I
nevertheless happen to learn very quickly :) I think my next big language
projects will be _really_ learning Perl, and Python.
That's why some of the pre-searching and latest-accepted-methology
recommendations drown me in additional parallel learning curves.
ACK
I looked at the jibbering faq to try and pick up on what etiquette I
may have breached (that seemed to be your implication), but there's
more stuff in there than I can assimilate in one visit.
You referred to another thread but you did not provide a message ID or
simply continued that thread. I assumed that you remembered the thread
and person you referred to; as that is not so, I think it does not matter
anymore.

However, it would be kind of you if you quoted the minimum of what you
are referring to and then provide attribution as to who wrote what,
see <URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1M arg> and
<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1L wQu>, 3rd example.
OT (again), I need to figure out how to log in here without my naked
email address
Hopefully not, because that would violate (Proposed) Standards, particularly
RFC1036 and RFC2822, let alone it would mean a disregardment of Netiquette
(as people may want to contact you privately for both your own and the
newsgroup's good).
because it just advertises 'open season' for spam. I get piles of it
shortly after each post.


Use an (existing, heavy-filtered, seldom-but-not-never-read) spam sink for
From address and an often-read (still spam-filtered) address for Reply-To,
like I do. If that is not possible, do not use Google Groups but a decent
newsreader program, as I would recommend to you anyway (Mozilla Thunderbird
on Windows, KNode on GNU/Linux). Most notably, Thunderbird Mail includes a
Bayesian (trainable [gr?]) spam filter that takes the spam the server-side
filter ignored; see <URL:http://www.paulgraham. com/spam.html>.

And do not hesitate to send _courteous_ complaint e-mails to the ISPs of
spammers (see e.g. X-Complaints-To headers and `whois`) so that they kick
those users (only in their back, if necessary :)), and notify admins of
Open Relays (see Received headers and `whois`) that they configure them
accordingly; use public real-time blacklists
(<URL:http://www.email-policy.com/Spam-black-lists.htm>) if possible.

In retrospect of now almost 5 years of Usenet experience, that approach
appears to me to be the best one, avoiding most of the spam while helping
to preserve the workings of the Net. See also

<URL:http://www.interhack.n et/pubs/munging-harmful/>
\V/ PointedEars
_______________
[1] <http://en.wikipedia.or g/wiki/KC_85>
Nov 23 '05 #5
JRS: In article <11************ *********@g44g2 000cwa.googlegr oups.com>,
dated Thu, 17 Nov 2005 02:15:03, seen in news:comp.lang. javascript,
murrayatuptowng allery <mu************ *******@yahoo.c om> posted :

<script type="text/javascript">
var AAA = new Array(4)

AAA[0] = 2*0.1*Math.roun d(10*Math.log(3 2)/Math.log(2))
AAA[1] = 2*0.1*Math.roun d(10*Math.log(1 6)/Math.log(2))
AAA[2] = 2*0.1*Math.roun d(10*Math.log(8 )/Math.log(2))
AAA[3] = 2*0.1*Math.roun d(10*Math.log(5 .656)/Math.log(2))
theTable='<tab le border="5"><tr> <td>';
theTable+=AA A[0];
theTable+='</td><td>';
theTable+=AA A[1];
theTable+='</td></tr><tr><td>';
theTable+=AA A[2];
theTable+='</td><td>';
theTable+=AA A[3];
theTable+='</td></tr></table>';
document.write (theTable);

</script>

Consider :

<script type="text/javascript">

function AAA(K) { return 2*0.1*Math.roun d(10*Math.log(K )/Math.log(2)) }

var AA = [[32, 16], [8, 5.656, 1.414]]

T = '<table border="5"><tr> <td>';
for (J=0 ; J<AA.length; J++) { AAJ = AA[J]
T += "<tr>"
for (K=0 ; K<AAJ.length ; K++)
T += "<td>" + "AAA(" + AAJ[K] + ") = " + AAA(AAJ[K]) + "<\/td>"
T += "<\/tr>" }
T += '<\/table>';
document.write( T);

</script>

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 23 '05 #6
Thanks P-E and Dr.S.

I used to fight spammers when I had a 5-10% 'kill' rate (satisfaction
that someone's account had been closed or billed for cleanup). Now most
responses are (possibly legitimate) denials it's their users, just a
forged address.

I will experiment some more with Dr Stockton's version. For the time
being I just went back to screen display and that's pretty messy.

I DO spend some time referring to standards/references. Sometimes it
helps, sometimes it shows you how deep the water actually is.

Murray

Nov 23 '05 #7
JRS: In article <11************ *********@g49g2 000cwa.googlegr oups.com>,
dated Sat, 19 Nov 2005 10:50:30, seen in news:comp.lang. javascript,
murrayatuptowng allery <mu************ *******@yahoo.c om> posted :

I DO spend some time referring to standards/references. Sometimes it
helps, sometimes it shows you how deep the water actually is.


In that case, perhaps you will refer to the newsgroup FAQ, to find out
how a news response should be formatted.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
26867
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
9
5688
by: Dean Ware | last post by:
I am trying to construct a model for use in a video game Basically I have boiled things down to the following situation that needs to be modelled:
1
3357
by: OM | last post by:
I am trying to present tree-structure information using a html table and JavaScript. Each tree node is displayed in the first column in a table row. The tree node can also have additional information in other table columns. To make the collapse / expand functionality I want to use JavaScript to display / hide table rows using row.style.display = "inline" / "none". To get references to the table rows they all need unique id's. I want
8
2849
by: Hardrock | last post by:
I encountered some difficulty in implementing dynamic loop nesting. I.e. the number of nesting in a for(...) loop is determined at run time. For example void f(int n) { For(i=0; i<=K; i++) For(i=0; i<=K; i++)
60
10140
by: Peter Olcott | last post by:
I need to know how to get the solution mentioned below to work. The solution is from gbayles Jan 29 2001, 12:50 pm, link is provided below: > http://groups.google.com/group/comp.lang.c++/msg/db577c43260a5310?hl > >Another way is to create a one dimensional array and handle the >indexing yourself (index = row * row_size + col). This is readily >implemented in template classes that can create dynamically allocated >multi-dimensional...
6
17315
by: finerrecliner | last post by:
hey everyone i'm trying to make a function that will return the length and width of a dynamically allocated 2D array. here's what i came up with to find width: int findWidth(int** matrix) { int width = 0;
9
6785
by: PeteCresswell | last post by:
I've got something called "Reference Rates". The idea is that on a given day, we have various rates of return for various entities. e.g. Libor 3-month return, Libor 6-month return, US Treasury Bonds, the Prime rate, and so-forth. We associate a security with one of those rates. There are a set of rates for each calendar day, and the rates for that
9
3746
by: dennis.sam | last post by:
Hi, Is there away to define a multi-dimensional array with respect to the number of dimensions the array has? For example, given a user spec of "a b c d", I want to create a 4 dimensional array with dimensional lengths of a, b, c and d. Thanx for any help.
7
3603
by: imtmub | last post by:
I have a page, Head tag Contains many Scripts and style sheet for Menu and Page. This code working fine and displaying menus and page as i wanted. Check this page for reference. http://www.marco.com.cn/web-content/marco_re10.html -------------------------------------------------------------- <head> <!-- InstanceBeginEditable name="doctitle" --> <title>Marco</title> <!-- InstanceEndEditable -->
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6122
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1507
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.