special rules using the IF statement

G

Guest

I have been having major problems with the IF statement.
it does not run through the whole script.
this is part of my script, to show you how my script is made up.
are their any rules on where the ; goes ?
or the { or }
I can not figure this out at all.

the following is in a file called showorders.htm, this file is displayed in
a table and its content is refreshed when a button in another table is
clicked.

does the extension .htm make a difference, do the files have to be .html
?

I have no idea what is wrong,

thanks for you help.
Jason




function showorders()
{

alert("start of show orders script")

var form = document.forms.favororders;

document.write("1");

if (form.Avocado.value!=0) {
document.write("Avocado ="+adddecimal((form.Avocado.value)*cAvocado));
}

alert("after the first if in show orders script")

if (form.ButterSquash.value!=0) {
document.write("ButterSquash
="+adddecimal((form.ButterSquash.value)*cButterSquash));
}

if (form.Cauliflower.value!=0) {
document.write("Cauliflower
="+adddecimal((form.Cauliflower.value)*cCauliflower));
}

if (form.CornOnCob.value!=0) {
document.write("CornOnCob
="+adddecimal((form.CornOnCob.value)*cCornOnCob));
}

if (form.Cucumber.value!=0) {
document.write("Cucumber
="+adddecimal((form.Cucumber.value)*cCucumber));
}

if (form.Garlic.value!=0) {
document.write("Garlic ="+adddecimal((form.Garlic.value)*cGarlic));
}

document.write("2");

if (form.Grapefruit.value!=0) {
document.write("Grapefruit
="+adddecimal((form.Grapefruit.value)*cGrapefruit));
}

}
 
R

Ronx

I would change form.Avocado.value to document.forms[0].Avocado.value
and similar changes for the rest of the fields, where [0] assumes the
form is the first form encountered on the page.
 
G

Guest

this time the "1" in the alert did not show at all.

the iframe name where the form is, is called orderpageiframe
the iframe name where the orders are shown is called showorderpageiframe

what else could this be.

this has been driving me mad for weeks now.

if there a rule for the ; at the end of the lines?


thanks



Ronx said:
I would change form.Avocado.value to document.forms[0].Avocado.value
and similar changes for the rest of the fields, where [0] assumes the
form is the first form encountered on the page.
--
Ron Symonds
Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.

I have been having major problems with the IF statement.
it does not run through the whole script.
this is part of my script, to show you how my script is made up.
are their any rules on where the ; goes ?
or the { or }
I can not figure this out at all.

the following is in a file called showorders.htm, this file is displayed
in a table and its content is refreshed when a button in another table is
clicked.

does the extension .htm make a difference, do the files have to be
.html ?

I have no idea what is wrong,

thanks for you help.
Jason




function showorders()
{

alert("start of show orders script")

var form = document.forms.favororders;

document.write("1");

if (form.Avocado.value!=0) {
document.write("Avocado
="+adddecimal((form.Avocado.value)*cAvocado));
}

alert("after the first if in show orders script")

if (form.ButterSquash.value!=0) {
document.write("ButterSquash
="+adddecimal((form.ButterSquash.value)*cButterSquash));
}

if (form.Cauliflower.value!=0) {
document.write("Cauliflower
="+adddecimal((form.Cauliflower.value)*cCauliflower));
}

if (form.CornOnCob.value!=0) {
document.write("CornOnCob
="+adddecimal((form.CornOnCob.value)*cCornOnCob));
}

if (form.Cucumber.value!=0) {
document.write("Cucumber
="+adddecimal((form.Cucumber.value)*cCucumber));
}

if (form.Garlic.value!=0) {
document.write("Garlic ="+adddecimal((form.Garlic.value)*cGarlic));
}

document.write("2");

if (form.Grapefruit.value!=0) {
document.write("Grapefruit
="+adddecimal((form.Grapefruit.value)*cGrapefruit));
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top