Re: if there a rule for the ; at the end of javascript lines ?Hi,
thanks again for help. it works.
the only problem i am now having is the IF statements i have added to complete the code.
i do not understand how it works.
i have looked on the web and found many ways like nested if and standard if else
but i only need to have an
if (condition) then dosomething endif
if (condition) then dosomething endif
if (condition) then dosomething endif
if (condition) then dosomething endif
where none of the conditions are related. ie, if condition then else type
below is the script as it stands now with just a few if the if statements.
the fomulas are ok, ie adddecimal... i am able to use just one of the if statements but have problems when i use more than one.
there must be a way to do this.
any ideas?
thanks again.
Jason
function showorders() {
myform = parent.orderpageiframe.document.favororders;
if (myform.Avocado.value) {
alert(Avocado);
document.write(myform.Avocado.value);
document.write("Avocado ="+adddecimal(myform.Avocado.value*cAvocado));
}
if (myform.ButterSquash.value) {
alert(ButterSquash);
document.write(myform.ButterSquash.value);
document.write("ButterSquash ="+adddecimal(myform.ButterSquash.value*cButterSquash));
}
if (myform.Cauliflower.value) {
alert(Cauliflower);
document.write(myform.Cauliflower.value);
document.write("Cauliflower ="+adddecimal(myform.Cauliflower.value*cCauliflower));
}
if (myform.CornOnCob.value) {
alert(CornOnCob);
document.write(myform.CornOnCob.value);
document.write("CornOnCob ="+adddecimal(myform.CornOnCob.value*cCornOnCob));
}
}
Jens Peter Karlsen said:
form = (document.forms.favororders);
This fails because there are no forms in the current document.
There isn't one in the main document either so I will assume that there are one in the other iframe. So change the above to this:
myform = parent.frames(orderpageiframe).document.forms(favororders);
That sets myform (do not use just "form") equal to the form named favororders in the parent documents iframe "orderpageiframe".
aaa=(document.favororders.Avocado);
The same as above goes for this.
myform2 = parent.frames(orderpageiframe).document.forms(Avocado);
This will fail. You need to access the values of the individual formfields and write these.
Why on earth you would want to do this is beyound me. People can already see what they entered in the form in the other iframe.
Perhaps if you described what you was hoping to achieve instead, it would be possible to help you with a solution.
Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
________________________________
From: cheers [mailto:cheers]
Posted At: 22. maj 2005 02:31
Posted To: microsoft.public.frontpage.programming
Conversation: if there a rule for the ; at the end of javascript lines ?
Subject: Re: if there a rule for the ; at the end of javascript lines ?
i do not get any errors!
it just does not complete to the end of the script.
to me its like i got a line wrong so it does not want to look at any other lines. and end returns to where it was called from, i think.
i have set show all error messages in the advanced tab of internet properties, also installed firefox and tried navigator, but none show errors, firefox did not show the update one of my frames/tables. but internet explorer does.
below are the file that i think will help you find out what i am doing
wrong.
my form name="favororders" this is in the favor_orderpage.htm file not
included. that file is working fine.
just a thought, but i noticed that there are table tags? in my htm
code, it is table2, not sure if i should be getting the form information
from the table of the form?
the information if taken from the form when the cost of the order is worked
out. this works, but getting the orders into the other window iframe is my
problem.
thanks
my showorders.js file
function showorders() {
alert("start show orders htm");
form = (document.forms.favororders);
alert("so1");
aaa=(document.favororders.Avocado);
alert("so2");
document.write(aaa);
alert("end show orders htm");
}
my showorders.htm file
<html>
<head>
<title>New Page 1</title>
<script type="text/javascript" src="showorders.js"></script>
</head>
<body>
<script type="text/javascript">
showorders()
</script>
</body>
</html>
my main.htm
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script type="text/javascript" src="showorders.js"></script>
<script type="text/javascript" src="adddecimal.js"></script>
<script type="text/javascript" src="costofitem.js"></script>
<script type="text/javascript" src="gettotal.js"></script>
<script type="text/javascript" src="resetall.js"></script>
<script type="text/javascript" src="clearorder.js"></script>
<script type="text/javascript">
//window.moveTo(0,0);
//window.resizeTO(1400,1424);
</script>
</head>
<body>
<table border="0" cellpadding="0" style="border-collapse: collapse"
width="983" height="651" id="table1">
<tr>
<td align="left" valign="top" width="164">
<table border="5" cellpadding="0" style="border-collapse: collapse"
width="162" id="table2" height="43" bordercolor="#808080">
<tr>
<td valign="top">
<table border="0" cellpadding="0" style="border-collapse: collapse"
width="151" id="totalcostcell">
<tr>
<td colspan="2">
<p align="center">Total Cost of your order</p>
</td>
</tr>
<tr>
<td width="28">
<p align="right">£</td>
<td width="123"><div id="theTotal"></div></td>
</tr>
</table>
</td>
</tr>
</table>
<table border="5" cellpadding="0" style="border-collapse: collapse"
width="162" id="orderlistcell" height="185" bordercolor="#800080">
<tr>
<td valign="top">
<iframe name="showorderpageiframe" width="142" height="561"
src="showorders.htm">
Your browser does not support inline frames or is currently configured not
to display inline frames.
</iframe>
</td>
</tr>
</table>
</td>
<td align="left" valign="top">
<iframe name="orderpageiframe" width="758" height="623"
src="favor_orderpage.htm" align="top" target="_blank" style="border-style:
ridge; border-width: 2px">
Your browser does not support inline frames or is currently configured not
to display inline frames.
</iframe></td>
</tr>
</table>
</body>
</html>
Do you have a frame (iframe or normal frame) that is called "showorderpageiframe" ?
What is the error message you receive?
Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
-----Original Message-----
From: cheers [mailto:cheers]
Posted At: 20. maj 2005 17:29
Posted To: microsoft.public.frontpage.programming
Conversation: if there a rule for the ; at the end of
javascript lines ?
Subject: Re: if there a rule for the ; at the end of
javascript lines ?
function resetall() {
alert("reset");
parent.totalcostcell.document.getElementById('theTotal').inner
HTML = ""; parent.showorderpageiframe.reload();
alert("end of reset");
}
this function is called ok, but the reload and end of reset
lines do not run.
if i comments out the reload line then the script works ok,
executing all lines.
what could be wrong with this line.
thanks
Jason
Jens Peter Karlsen said:
Change to:
function resetall() {
alert("reset");
parent.totalcostcell.document.getElementById('theTotal').innerHTML="";
parent.showorderpageiframe.reload();
alert("end of reset");
}
Unlike vbscript, javascript requires that each statement is ended with
an ; and in most cases it must be on one line.
Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
cheers wrote:
function resetall() {
alert("reset") // works
parent.totalcostcell.document.getElementById('theTotal').inner
HTML = ""
// works
parent.showorderpageiframe.reload() // does NOT work
alert("end of reset") // does NOT work
}
the above is a shorter version with comments on what work and not work
is it in a .js file called resetall.js
<cheers> wrote in message
i have had problems with my .js files
i have a file that is shown below and it does not complete to the end.
does anyone know why?
is it something to do with the ;
?
also where on the net can i get help with how to included? the .js
file within a htm file correctly?
i think this might also be my problem?
thanks
function resetall() {
alert("reset");
parent.totalcostcell.document.getElementById('theTotal').in nerHTML =
""; parent.showorderpageiframe.reload();
//blank all variables for items bought Avocado=0; ButterSquash=0;
Cauliflower=0; CornOnCob=0; Cucumber=0; Garlic=0; Grapefruit=0;
GreenCabbage=0; HoneyDewMelon=0; KiwiFruit=0; Lemons=0;
ctotal=0;
alert("end of reset");
}