Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Math on a website

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
A great project I started myself was to create a website with some pre-set formulas on it. Something that would be like a spreadsheet, on a site.

What I am hoping to do is to have a bunch of text boxes (lets say 3) that would act as variables in the formula. Lets say my preset formula was something like: X + Y - Z + 100... Text Box 1 would represent X, Text Box 2 would represent Y, and Text Box 3 would represent Z.

I want it to be that when a person enters 10 in the first box, 5 in the second, and 8 in the third, the fourth box would say "107", (since 10+5-8+100=107).

This is just a short example. I'm looking to do something way more complicated with a lot of variables.

Is this something that could be done simply with HTML? CGI? Can someone recommend a site/book/language that I can look into to help me achieve my goal?

I would also like to make it so if the user looks at the source, they would not be able to trace the formula (They would have to come back to the website to use the formula =) ). Someone please let me know if its possible and how I would go about doing this.

I am greatful for any help.
 
Javascript would be adequate! I once wrote an entire statistical analysis program that could handel 1000's of variables at a time...

Per Your Example:
Code:
<html>
<head>
 <script language=&quot;javascript&quot;>
 function calc(){
 var x = parseInt(document.FormName.X.value);
 var y = parseInt(document.FormName.Y.value);
 var z = parseInt(document.FormName.Z.value);
 document.FormName.answer.value = (((x+y)-z)+100);
 }
 </script>
</head>
<body>
<form name=&quot;FormName&quot;>
 X = <input type=&quot;text&quot; name=&quot;X&quot;><br>
 Y = <input type=&quot;text&quot; name=&quot;Y&quot;><br>
 Z = <input type=&quot;text&quot; name=&quot;Z&quot;><br>
 Answer = <input type=&quot;text&quot; name=&quot;answer&quot;>
 <input type=&quot;button&quot; value=&quot;CALCULATE&quot; onClick=&quot;calc();&quot;>
</form>
</body>
</html>

This should do it! This might seem confusing if you're new to programming, but there are quite a few people around these forums to help! -gerrygerry
Go To
 
Thanks a lot for you help gerrygerry. Your help was very useful.
 
To make it so they can't read the source code you might wan't to use another script to scramble it. I know I have one somewhere, I'll look for it.
Midnike
 
Rather than scramble your code, if it is in JavaScript, you could put the code in a .js file and call it using the src part of the script tag. If I'm not mistaken, a user should be not able to actually access the .js file itself (although the file with the code would still run in the webpage), hence being unable to examine the code.

Hope that helps.

JavaDude32
 
Any one that can interpret your source code can locate the external .js file and download it. There is no way to protect your source code... only deterances -gerrygerry
Go To
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top