Skip to content

Instantly share code, notes, and snippets.

@criscokid
Forked from anonymous/gist:70018
Created February 25, 2009 05:19
Show Gist options
  • Save criscokid/70033 to your computer and use it in GitHub Desktop.
Save criscokid/70033 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">
function processForm() {
var var1= document.myform.num1.value;
//alert (var1); //test for the value the user types in
var thisOperation = document.myform.thisOperator.value;
//alert (thisOperation);
if(thisOperation == "em")
{
var result = var1 * 0.0625;
var myMessage = result + ' em';
}
if(thisOperation == "px")
{
var result = var1 / 0.0625;
var myMessage = result + ' px';
}
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">
<select name="thisOperator">
<option value="em">Convert to EMs</option>
<option value="px">Convert to Pi</option>
</select><br />
<input type="submit" name="submit" value="Calculate"><br />
<input type="text" name="results" style="width:270px;">
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment