The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Need help with “if” statements and combining javascript Re: Need help with “if” statements and combining javascript


Wow, this looks like code from hell. ;)

I realy tryed to figure out what you are tring to achive in your code, but have no idea. What framework causes such code? Maybe we can solve your problem on an abstract level.

If I got you right, you have two sripts A and B (different functions or files or what?). Normaly if you want the execution of B to be dependet of the execution of A you have store the decission from A in variable or a flag (or use the same if condition in B). You can now make your decission in B based on the flag or variable you have created in A.

var flag;

function A() {
if (unit == "EA") {
flag = "EA" /* you can also store a calculated value */
else if (unit == "TH") {
flag = "TH"
document.write("..." );

function B() {
if (flag == "EA") {
/* do it for each */
else if (flag == "TH") {
/* do it for thousands */

Maybe this is a push in the right direction.

PS: Try using the code blocks in your posts. It makes the code much more readable.