Forum Moderators: open

Message Too Old, No Replies

new to javascript - write script

         

quartzy

10:21 am on Feb 27, 2009 (gmt 0)

10+ Year Member



I need to write a script that will collect weights of people, then write their weight, I have made a start, but I dont know what to do next, how can I get another script below this one? I thought maybe a switch statement would work, just need ideas really as well.
<code>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
</head>
<body>

<script type="text/javascript">
/* <![CDATA[ */
function disp_prompt()
{
var ask=prompt("Please enter your weight in kilograms");
{
document.write("Thank-you");
}
}

/* ]]> */
</script>
<h2>Click here to evaluate your weight</h2>
<input type="button" onclick="disp_prompt()" value="Click here" />
</body>
</html>
</code>

birdbrain

11:59 am on Feb 28, 2009 (gmt 0)



Hi there quartzy,

does this help in any way...


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title></title>

<style type="text/css">
#reply {
margin-top:20px;
color:#600;
}
.hide {
display:none;
}
</style>

<script type="text/javascript">
if(window.addEventListener){
window.addEventListener('load',init,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',init);
}
}
function init(){

document.getElementById('mybut').onclick=function() {
disp_prompt();
}
}

function disp_prompt(){

document.getElementById('reply').firstChild.nodeValue='';

ask=prompt('Please enter your weight in kilograms.\nSomething like this - "123"','');

if(isNaN(ask)¦¦(ask=='')){
alert('The value entered should be a number, as indicated');
disp_prompt();
}

if(ask==null) {
alert('So you are not interested in the project.\nFair enough it will be removed');
document.getElementById('container').className='hide';
return;
}

document.getElementById('reply').firstChild.nodeValue=
'The weight that you entered was ' +ask+' kilograms.';
}

</script>

</head>
<body>

<div id="container">

<h2>Click here to evaluate your weight</h2>

<div>
<input id="mybut" type="button" value="Click here">
</div>

<div id="reply">&nbsp;</div>

</div>

</body>
</html>


birdbrain

quartzy

1:00 pm on Feb 28, 2009 (gmt 0)

10+ Year Member



hi
thanks for getting back to me, but that script does not work, but it is OK now, as I have moved onto for and while statements. Got to find out how to do them.