|
Posted by Toby Inkster on 01/04/07 14:50
Geoff wrote:
> Can this be done in HTML alone
No -- you will need some form of scripting. There are basically two
options:
- Client side (using Javascript)
- Server side (big choice of scripting languages)
Client side is very easy, but not completely reliable, as not everyone
uses Javascript-enabled browsers. Here's a quick example:
<input name="string" id="stringid">
<input type="button" id="buttonid">
<script type="text/javascript">
function checkit ()
{
var it = document.getElementById('stringid');
window.alert(it.value.length()==15 ? 'You win!' : 'You lose!');
}
document.getElementById('buttonid').onclick = checkit;
</script>
With server-side scripting, you'll need to find out which languages your
server supports. Many servers support PHP, so here's a PHP example:
<form action="<?=$_SERVER['PHP_SELF']?>" method="get">
<input name="string">
<input type="submit">
</form>
<?= (strlen($_GET['string'])==15 ? 'You win!' : 'You lose!'); ?>
> Secondly, I want the number that has been entered, to be added to a list
> on a hidden page.
This will certainly require server-side scripting. Client-side would not
be capable of this.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Navigation:
[Reply to this message]
|