Skip to content

Instantly share code, notes, and snippets.

Created February 25, 2009 04:51
Show Gist options
  • Save anonymous/70018 to your computer and use it in GitHub Desktop.
Save anonymous/70018 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>My Calc</title>
<META name="Author" content="Phil">
</head>
<script type="text/javascript" src="calc_nums_only.js"></script>
<script type="text/javascript">
//alert ("test");
function processForm() {
//alert ("test")// is the function being called?
var var1= document.myform.num1.value;
//alert (var1); //test for the value the user types in
var thisOperation = document.myform.thisOperator.value;
// alert (thisOperation);
var myResult = eval(num1 + thisOperator);
var myMessage = "";
if(thisOperation == "Option1"){ // operation is Option 1
//alert ("this")
myResult = eval(var1 + thisOperation);
// myMessage = " whatever you tell the user as a result here";
} else { // operation is Option 2
//alert ("the other")
myResult = eval(var1 + thisOperation);
// myResult =... // your formula goes here
//myMessage = " whatever you tell the user as a result here";
}
document.myform.results.value = myMessage;
}
/***********/
</script>
<body>
<h2>My Whatever Converter</h2>
<form action="javascript:processForm()" method="post" name="myform">
<input type="text" name="num1" onkeypress="return numbersonly(this,event)">
<select name="thisOperator">
<option value="*0.0625">Convert to EMs</option>
<option value="/0.0625">Convert to Pi</option>
</select><br />
<input type="submit" name="submit" value="Calculate"><br />
<input type="text" name="results" onkeypress="return numbersonly(this,event)" style="width:270px";>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment