saving scripts

E

EL

When I copy free scripts online where and how do I save
them. I read that you should place it in notepad first
for some reason. Thanks in advance
 
S

Steve Easton

Yes, copy them to notepad first, as it removes any "formatting" from the web page it was copied
from.
If you want to save the script for future use, simply click Save As in notepad and give it a name
and save it as a text file.


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
E

EL

Thank you. Ok next question if I use behaviours I can add
a script 'call script' how do I do this? Thank you.
FP 03
-----Original Message-----
Yes, copy them to notepad first, as it removes
any "formatting" from the web page it was copied
from.
If you want to save the script for future use, simply
click Save As in notepad and give it a name
 
S

Steve Easton

A call script is a script saved in a .js file. To create a .js file place the script you want in
notepad.
Remove: <script type="text/javascript"> from the beginning and </script> from the end and then Save
As. myscript.js
or whatever name.js you want.

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
T

thank you

how do you call this script from the html file, and when do you save this
name.js file.

thank you
 
S

Steve Easton

Call it from the head section of the page using:

<script type=text/javascript src="name.js">
</script>

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
J

java script help needed

i am having trouble with adding numbers in java, i have the following java
script that is not working correctly, any ideas how to get it to work right,
i know there is a simple answer but i have been trying for days to get it to
work.





<script language="JavaScript"><!--
function Morgcal()
{
form = document.myform
sum1= form.num1.value
sum2= form.num2.value
sum3= form.num3.value
sum4= form.num4.value

sum=0

ctotal=(sum1)
ctotal=ctotal+(sum2)
ctotal=ctotal+(sum3)
ctotal=ctotal+(sum4)

form.total.value=Math.floor(ctotal)
}
// --></script>




thanks
 
J

Jens Peter Karlsen[FP-MVP]

Change to:

<script language="JavaScript"><!--
function Morgcal()
{
var form = document.forms.myform;
var sum1 = form.num1.value;
var sum2 = form.num2.value;
var sum3 = form.num3.value;
var sum4 = form.num4.value;

var sum = 0; //this is never used?

var ctotal = sum1;
ctotal = ctotal+sum2;
ctotal = ctotal+sum3;
ctotal = ctotal+sum4;

form.total.value = Math.floor(ctotal);
}

Could be shortened to:

var form = document.forms.myform;
var sum1 = form.num1.value + form.num2.value + form.num3.value +
form.num4.value;
form.total.value = Math.floor(sum1);


Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.

-----Original Message-----
From: java script help needed [mailto:thank you for your help]
Posted At: 25. juli 2004 17:58
Posted To: microsoft.public.frontpage.programming
Conversation: saving scripts
Subject: Re: saving scripts


i am having trouble with adding numbers in java, i have the following
java script that is not working correctly, any ideas how to get it to
work right, i know there is a simple answer but i have been trying for
days to get it to work.





<script language="JavaScript"><!--
function Morgcal()
{
form = document.myform
sum1= form.num1.value
sum2= form.num2.value
sum3= form.num3.value
sum4= form.num4.value

sum=0

ctotal=(sum1)
ctotal=ctotal+(sum2)
ctotal=ctotal+(sum3)
ctotal=ctotal+(sum4)

form.total.value=Math.floor(ctotal)
}
// --></script>




thanks
 
J

java script help needed

I copied this and it joined all of the numbers as thought they were text not
numbers, :-(

it has to add them as figures,

any more ideas

thanks




Jens Peter Karlsen said:
Change to:

<script language="JavaScript"><!--
function Morgcal()
{
var form = document.forms.myform;
var sum1 = form.num1.value;
var sum2 = form.num2.value;
var sum3 = form.num3.value;
var sum4 = form.num4.value;

var sum = 0; //this is never used?

var ctotal = sum1;
ctotal = ctotal+sum2;
ctotal = ctotal+sum3;
ctotal = ctotal+sum4;

form.total.value = Math.floor(ctotal);
}

Could be shortened to:

var form = document.forms.myform;
var sum1 = form.num1.value + form.num2.value + form.num3.value +
form.num4.value;
form.total.value = Math.floor(sum1);


Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.

-----Original Message-----
From: java script help needed [mailto:thank you for your help]
Posted At: 25. juli 2004 17:58
Posted To: microsoft.public.frontpage.programming
Conversation: saving scripts
Subject: Re: saving scripts


i am having trouble with adding numbers in java, i have the following
java script that is not working correctly, any ideas how to get it to
work right, i know there is a simple answer but i have been trying for
days to get it to work.





<script language="JavaScript"><!--
function Morgcal()
{
form = document.myform
sum1= form.num1.value
sum2= form.num2.value
sum3= form.num3.value
sum4= form.num4.value

sum=0

ctotal=(sum1)
ctotal=ctotal+(sum2)
ctotal=ctotal+(sum3)
ctotal=ctotal+(sum4)

form.total.value=Math.floor(ctotal)
}
// --></script>




thanks



Steve Easton said:
Call it from the head section of the page using:

<script type=text/javascript src="name.js"> </script>

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

"thank you" <thanks again> wrote in message news:%[email protected]...
 
J

java script help needed

<html>

<head>

<script language="JavaScript">
num1=0;
num2=0;
num3=0;
num4=0;
cnum1=2;
cnum2=3;
cnum3=4;
cnum4=5;
</script>




<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 4</title>
</head>

<body>

<form action="POST" name="myform">
<table border="1" bgcolor="#63639C" width="608">
<tr>
<td width="598">








<script language="JavaScript"><!--
function Morgcal()
{
var form = document.forms.myform;
var sum1 = form.num1.value;
var sum2 = form.num2.value;
var sum3 = form.num3.value;
var sum4 = form.num4.value;

var sum = 0; //this is never used?

var ctotal = sum1;
ctotal = ctotal+sum2;
ctotal = ctotal+sum3;
ctotal = ctotal+sum4;

form.total.value = Math.floor(ctotal);
}
// --></script>








<table border="0" cellpadding="2" width="645" height="163">
<tr>
<td align="right" width="304" height="41">
<font face="arial narrow" size="5" color="#FFFFFF">num 1
</font></td>
<td width="129" height="41">
<font color="#FFFFFF" size="5"
face="arial narrow">
<input type="text"
size="10" name="num1" value="80"
onblur="Morgcal()" onchange="Morgcal()"></font></td>
</tr>
<tr>
<td align="right" width="304" height="24">
<font face="arial narrow" size="5" color="#FFFFFF">num
2</font></td>
<td width="129" height="24">
<font color="#FFFFFF" size="5"
face="arial narrow">
<input type="text"
size="10" name="num2" value="6"
onblur="Morgcal()" onchange="Morgcal()"></font></td>
</tr>
<tr>
<td align="right" width="304" height="24">
<font face="arial narrow" size="5" color="#FFFFFF">num
3</font></td>
<td width="129" height="24">
<font color="#FFFFFF" size="5"
face="arial narrow">
<input type="text"
size="10" name="num3" value="20"
onblur="Morgcal()" onchange="Morgcal()"></font></td>
</tr>
<tr>
<td align="right" width="304" height="48">
<font face="arial narrow" size="5" color="#FFFFFF">num
4</font></td>
<td width="129" height="48">
<font color="#FFFFFF" size="5"
face="arial narrow">
<input type="text"
size="10" name="num4" value="20"
onblur="Morgcal()" onchange="Morgcal()"></font></td>
<td width="357" height="48">
<font color="#FFFFFF" size="5"
face="arial narrow"><input type="button"
name="morgcal" value="Calculate"
language="JavaScript" onclick="Morgcal()"> </font></td>
</tr>


</table>
</td>
</tr>
<tr>
<td width="598"><table border="0" cellpadding="2">
<tr>

<td align="right">
<font face="arial narrow" color="#FFFFFF" size="5">total
</font></td>
<td>
<font color="#FFFFFF" size="5"
face="arial narrow">
<input type="text"
size="7" name="total"></font></td>
</tr>
</table>
</td>
</tr>
</table>
</form>


</body>

</html>
 
J

java script help needed

i have sent in last message the full html coding, of my test page to add
numbers up, it will be used to make up a very large file that has about 100
numbers.

i have to do this in html/java as my server does not support other codes,
its a free site.

hope you are able to get it to work.


thank you agian





Jens Peter Karlsen said:
Change to:

<script language="JavaScript"><!--
function Morgcal()
{
var form = document.forms.myform;
var sum1 = form.num1.value;
var sum2 = form.num2.value;
var sum3 = form.num3.value;
var sum4 = form.num4.value;

var sum = 0; //this is never used?

var ctotal = sum1;
ctotal = ctotal+sum2;
ctotal = ctotal+sum3;
ctotal = ctotal+sum4;

form.total.value = Math.floor(ctotal);
}

Could be shortened to:

var form = document.forms.myform;
var sum1 = form.num1.value + form.num2.value + form.num3.value +
form.num4.value;
form.total.value = Math.floor(sum1);


Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.

-----Original Message-----
From: java script help needed [mailto:thank you for your help]
Posted At: 25. juli 2004 17:58
Posted To: microsoft.public.frontpage.programming
Conversation: saving scripts
Subject: Re: saving scripts


i am having trouble with adding numbers in java, i have the following
java script that is not working correctly, any ideas how to get it to
work right, i know there is a simple answer but i have been trying for
days to get it to work.





<script language="JavaScript"><!--
function Morgcal()
{
form = document.myform
sum1= form.num1.value
sum2= form.num2.value
sum3= form.num3.value
sum4= form.num4.value

sum=0

ctotal=(sum1)
ctotal=ctotal+(sum2)
ctotal=ctotal+(sum3)
ctotal=ctotal+(sum4)

form.total.value=Math.floor(ctotal)
}
// --></script>




thanks



Steve Easton said:
Call it from the head section of the page using:

<script type=text/javascript src="name.js"> </script>

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

"thank you" <thanks again> wrote in message news:%[email protected]...
 
J

java script help needed

below is the screipt that i am now having trouble with it is showning in the
total form box

NaN

i think it means Not A Number ??

can anyone answer how to get it to show the figures of the total.


thanks




<script language="JavaScript"><!--
function Gettotal()
{
var form = document.forms.OrderForm;

sum=form.Mushrooms.value;
ctotal=sum;
sum=form.WhitePotatoes.value;
ctotal+=sum;
sum=form.GreenApples.value;
ctotal+=sum;
sum=form.RedApples.value;
ctotal+=sum;

form.total.value = Math.floor(ctotal);
}
// --></script>
 
J

java script help needed

I have now solved the

NaN issue, but still it now shown the numbers add as thought they are
strings,

a=1
b=2
c=3

d=a+b
d=d+c
d=123

should be 6


the script to add them is



<script language="JavaScript"><!--
function Gettotal()
{
var form = document.forms.myform;
var d = form.a.value;
var d = d + form._b.value;
var d = d + form.c.value;

form.total.value = Math.floor(d);
}

// --></script>
 
K

Kevin Spencer

The "+" operator is used to both concatenate strings and add numbers. Which
one it does depends on the data type of the values being applied to. Use the
parseInt() function to convert strings to numbers prior to adding them.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

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