running a script from another html page

- English -

Resident Freddy
Joined
Apr 7, 2004
Messages
5,263
Hello

Ive basically got 2 HTML pages, and one has a button to run the script

Code:
<input type=button value="Calculate Score" onclick="runScript();">

the script is in another html file called functionscript, which basically just calculates some numbers and prints out the result.

Is there anyway to reference or link this so it will work when i press the calculate score button?

Thanks!
 

Chronictank

FH is my second home
Joined
Jan 21, 2004
Messages
10,133
out of curiosity why is the script in a html file?,
You should really have it in a seperate file on the server so that someone can't just download the page (and subsequently all of your code) and work out exploits for it
 

- English -

Resident Freddy
Joined
Apr 7, 2004
Messages
5,263
out of curiosity why is the script in a html file?,
You should really have it in a seperate file on the server so that someone can't just download the page (and subsequently all of your code) and work out exploits for it

Its only for an assignment and I wont be hosting it anywhere, so I was just gonna put it in a folder together :)
 

Chronictank

FH is my second home
Joined
Jan 21, 2004
Messages
10,133
Its only for an assignment and I wont be hosting it anywhere, so I was just gonna put it in a folder together :)
principle is the same though, what did you write the calculator in? (assumably javascript?)
You just dump the script in the site folder somewhere and you can use it anywhere
 

- English -

Resident Freddy
Joined
Apr 7, 2004
Messages
5,263
yep,

all i want to do is when i click calculate, it will run the script from another file. Not sure how to reference the link in the calculate button ;s
 

- English -

Resident Freddy
Joined
Apr 7, 2004
Messages
5,263
Code:
<p><input type=button value="Calculate Score" onclick="runScript();">
<input type=reset value="Clear Form"></p>

if the script is in the same file, it will work. When it is in a different file in the same folder - it doesnt. Im assuming i need to reference to the script file somewhere? ;s
 

Chronictank

FH is my second home
Joined
Jan 21, 2004
Messages
10,133
Sorry i misread what you were doing

Surely it would be better to do the calculation on submit, so at the top it would be on submit = "your script"

You could try referecing the script above the header tag and calling the function on click
 

- English -

Resident Freddy
Joined
Apr 7, 2004
Messages
5,263
thats what im trying to do, but dont know how to reference it!!!!:)
 

Syri

FH is my second home
Joined
Jan 4, 2004
Messages
1,019
this page might be useful. Basically, put the javascript into a .js file, for example calculator.js, then put <script type="text/javascript" src="calculator.js"></script> in the <head> section of the page that needs to reference the script. you can then call any functions within calculator.js
 

Users who are viewing this thread

Top Bottom