Sorry to bother you with another beginner issue here, but I fail to see why this code doesn't work.
What should happen is that once the bet is validated in the function betcheck, the value should be shown in the div for control.
It doesn't. Why ?
What I want to do, of course, is transfer the user input to an internal variable for the rest of the code. I fail to see what I'm doing wrong here.
Could anybody point me in the right direction ?
Pascal.
I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
What should happen is that once the bet is validated in the function betcheck, the value should be shown in the div for control.
It doesn't. Why ?
Code:
<html>
<head>
<script language="javascript">
bet=0;
purse=20;
function betcheck(){
var bForm;
var result=false;
var numericExpression = /^[0-9]+$/;
bForm = document.userspace;
if(bForm.betamount.value.length!=0){
if(bForm.betamount.value.match(numericExpression)){
if(bForm.betamount.value<=purse){
bet=bForm.betamount.value;
document.getElementById('checkbet').innerHTML=bet;
result=true;
}
}
}
return(result);
}
function play(){
document.getElementById('winresult').innerHTML='';
if(betcheck){
document.getElementById('winresult').innerHTML='go';
}else{
document.getElementById('betamount').value="";
document.getElementById('winresult').innerHTML='no go';
}
}
</script>
</head>
<body>
<div id="play">
<form id="userspace">
Que voulez-vous parier ? <input type="text" id="betamount" name="betamount"/>
<input type="button" onclick="play()" value="Play" />
</form>
</div>
<div id="winresult">
</div>
<div id="checkbet">
</div>
</body>
</html>
What I want to do, of course, is transfer the user input to an internal variable for the rest of the code. I fail to see what I'm doing wrong here.
Could anybody point me in the right direction ?
Pascal.
I've got nothing to hide, and I'd very much like to keep that away from prying eyes.