Skip to content

Instantly share code, notes, and snippets.

@lawlesst
Created May 19, 2012 18:36
Show Gist options
  • Save lawlesst/2731883 to your computer and use it in GitHub Desktop.
Save lawlesst/2731883 to your computer and use it in GitHub Desktop.
View code for a basic PHP app that calculates prime numbers.
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="http://blueprintcss.org/blueprint/screen.css" type="text/css">
<link rel="stylesheet" href="http://blueprintcss.org/blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<style>
body {
padding: 3em;
}
h2 a, a.number:hover, p.startover a:hover {
border-bottom: 1px gray dashed;
}
a.number, h1 a, p.startover a {
text-decoration: none;
}
h1 a:hover {
border-bottom: 3px gray dashed;
}
div.notice, div.info, div.error {
width: 40em;
}
em {
font-weight: bold;
}
fieldset {
width: 40em;
}
ul.number-list {
margin-left: 3em;
list-style-type: circle;
}
span.show-next-msg {
color: #205791;
}
</style>
<body>
<div class="container">
<h1><a href="./">Prime numbers</a></h1>
<div id="numbers" class="span 7"><?php include('prime.php'); ?></div>
<div>
<form action="./" method="get" id="number-form">
<fieldset>
<label for="number-input" id="form-label">
Enter a number to see the next 10 primes
</label>
<br>
<input type="text" name="number" id="number-input" class="text"/>
<input type="submit" value="Show Next Primes" />
</fieldset>
</form>
</div>
<p class="startover">
<a href="./">Start over</a>
</p>
</div>
<script>
//Handle clicks on a prime number and set the prime form value to the clicked number.
function showNext(num) {
var form = document.forms['number-form'];
form.elements["number"].value = num;
document.getElementById('form-label').innerHTML= "<span class=\"show-next-msg\"><span class=\"marker\">&lowast;</span>&nbsp;Click button to see next 10 primes</span>";
return false;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment