2

I'm developing a scientific calculator and I've addded a feature that solves linear equations too. Here you can see the link to the page. When you click on Sistemi you see a new page with some input fields and the button "Solve".

<form name="sis1grado" action="sistema1.js">
<p align="center"><input id="x1" type="text" name="usrname" style="width:42px"> x  +  <input id="x2" type="text" name="usrname" style="width:42px"> y  =  <input id="x3" type="text" name="usrname" style="width:42px"></p>
<p align="center"><input id="x4" type="text" name="usrname" style="width:42px"> x  +  <input id="x5" type="text" name="usrname" style="width:42px"> y  =  <input id="x6" type="text" name="usrname" style="width:42px"></p>
<br>
<table width="216px" border="0" align="center">
<td width="16px">
<img src="http://i1087.photobucket.com/albums/j475/BetoMan0/graffapar.png" />
</td>
<td width="90px">
x = <input id="totx" type="text" name="usrname" style="width:42px">
<br>
<br>
y = <input id="toty" type="text" name="usrname" style="width:42px">
</td>
<td width="110px">
<p align="center"><INPUT TYPE="submit" Value="Solve"></p>
</td>
</table>
</form>

This is the code of the "Sistemi" page. In the same folder as calcolatricecs.html I have a js file called sistema1.js. It contains a function, called s1(), that has the code I must use for solve the equation (click here to see that the js file).

When I click the button Solve I'd like solve the equation calling the s1() function. To do this, I put <form name="sis1grado" action="sistema1.js"> and I also gave to my input the attribute submit as you can see.

This way is not working to me because when I click the button, anything happen. What could I do?

1 Answer 1

3

Add an onclick handler to your button:

<INPUT TYPE="submit" Value="Solve" onclick="s1();">

Also, be sure to reference your JS file with <script> tags.

Sign up to request clarification or add additional context in comments.

8 Comments

Do I have to remove action="sistema1.js" ?
I've made what you said, but it doesn't work. If you look at my page, click Sistemi, try to fill the gaps with some numbers and press Solve, anything happen
I see in the console that s1 is not defined, are you referencing your external JS anywhere? I didn't see it in the page source.
You need to make a reference to the actual script <script src="sistema1.js"></script>
Yes, since there is no reference to the script right now, it has no idea what s1(); is when it's being called.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.