...

View Full Version : Help me to find the mistakes ??????



german_89
10-06-2008, 10:58 AM
I have this programm, but there are some mistakes and I wanted some help.
Outcome: Some general information, outlining the daily nutritional requirements for boys and girls.


<html>
<head>
<title>i hope this works</title>
<style>
body
{
background-color:white;
}
p {
color:black;
font-family:"neverwinter";
font-size:20pt;
font-weight: bolder;
position:relative;
left:52px;
}
</style>
<script language="Text/Javascript">
var gen="null";
var age="null";
var both=new Array[4];
both[0]=1300; // calcium
both[1]=1500; //sodium low
both[2]=2300; //sodium high
both[3]=300; // cholesterol

var female=new Array[8];
female[0]="55"; //lowest normal fat
female[1]="78"; // highest normal fats
female[2]="22"; // saturated fats
female[3]="2000"; // calories
female[4]="46"; // protein
female[5]="15"; // iron
female[6]="2333"; // vitamin a
female[7]="23"; // fibre

var male=new Array[10];
male[0]="61"; // lowest total fats
male[1]="95"; // highest total fats
male[2]="24"; // lowest saturated fats
male[3]="27"; // hihgest saturated fats
male[4]="2200"; // lowest calories
male[5]="2400"; // highest calories
male[6]="52"; // protein
male[7]="11"; // iron
male[8]="3000"; // vitamin a
male[9]="32.5"; // fibre

//no more arrays, new variables to have values assigned to them so they can be calculated later on.
// these values will contain raw values that will be later assigned in the calculation stage.
var fats="null"; // normal fats
var sf="null"; // saturated fats
var cal="null"; // calories
var pro="null"; // protein
var iron="null"; // iron
var vita="null"; // vitamin A
var fibre="null"; // fibre
var sod="null"; // sodium

function check()
{
gender=document.dataform.gender.value;
age=document.dataform.age.value;
alert(gender+" "+age);
}

function test()
{
alert("****");
}
</script>
</head>
<body>
<h1 align="center">Application Programming</h1>
<hr>
<form name="dataform">
<table align="center" border="1" cellpadding="1" width="300px">
<tr>
<td colspan="2">Please select your age and gender</td>
</tr>
<tr>
<td align="right" width="148px">Age :</td>
<td align="left"><select name="age">
<option value="1"> </option>
<option value="14">14 Years Old</option>
<option value="15">15 Years Old</option>
<option value="16">16 Years Old</option>
<option value="17">17 Years Old</option>
<option value="18">18 Years Old</option>
</select>
</td>
</tr>
<tr>
<td align="right">Gender :</td>
<td align="left"><select name="gender">
<option value="2"> </option>
<option value="0">Female</option>
<option value="1">Male</option>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" value="Maths" onclick=test();></td>
</tr>
</table>
</form>
</body>
</html>

vwphillips
10-06-2008, 11:25 AM
<html>
<head>
<title>i hope this works</title>
<style>
body
{
background-color:white;
}
p {
color:black;
font-family:"neverwinter";
font-size:20pt;
font-weight: bolder;
position:relative;
left:52px;
}
</style>
<script type="text/javascript" >
var gen="null";
var age="null";
var both=new Array(4);
both[0]=1300; // calcium
both[1]=1500; //sodium low
both[2]=2300; //sodium high
both[3]=300; // cholesterol

var female=new Array(8);
female[0]="55"; //lowest normal fat
female[1]="78"; // highest normal fats
female[2]="22"; // saturated fats
female[3]="2000"; // calories
female[4]="46"; // protein
female[5]="15"; // iron
female[6]="2333"; // vitamin a
female[7]="23"; // fibre

var male=new Array(10);
male[0]="61"; // lowest total fats
male[1]="95"; // highest total fats
male[2]="24"; // lowest saturated fats
male[3]="27"; // hihgest saturated fats
male[4]="2200"; // lowest calories
male[5]="2400"; // highest calories
male[6]="52"; // protein
male[7]="11"; // iron
male[8]="3000"; // vitamin a
male[9]="32.5"; // fibre

//no more arrays, new variables to have values assigned to them so they can be calculated later on.
// these values will contain raw values that will be later assigned in the calculation stage.
var fats="null"; // normal fats
var sf="null"; // saturated fats
var cal="null"; // calories
var pro="null"; // protein
var iron="null"; // iron
var vita="null"; // vitamin A
var fibre="null"; // fibre
var sod="null"; // sodium

function check()
{
gender=document.dataform.gender.value;
age=document.dataform.age.value;
alert(gender+" "+age);
}

function test()
{
alert("****");
}
</script>
</head>
<body>
<h1 align="center">Application Programming</h1>
<hr>
<form name="dataform">
<table align="center" border="1" cellpadding="1" width="300px">
<tr>
<td colspan="2">Please select your age and gender</td>
</tr>
<tr>
<td align="right" width="148px">Age :</td>
<td align="left"><select name="age">
<option value="1"> </option>
<option value="14">14 Years Old</option>
<option value="15">15 Years Old</option>
<option value="16">16 Years Old</option>
<option value="17">17 Years Old</option>
<option value="18">18 Years Old</option>
</select>
</td>
</tr>
<tr>
<td align="right">Gender :</td>
<td align="left"><select name="gender">
<option value="2"> </option>
<option value="0">Female</option>
<option value="1">Male</option>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" value="Maths" onclick="test();"></td>
</tr>
</table>
</form>
</body>
</html>

german_89
10-07-2008, 04:49 AM
I tried but again is something wrong with ARRAYS ...........



<html>
<head>
<title>Programm</title>
<style>
body
{
background-color:white;
}
p {
color:black;
font-family:"neverwinter";
font-size:20pt;
font-weight: bolder;
position:relative;
left:52px;
}
</style>
<script type="text/javascript" >
var gen="null";
var age="null";
var both=new Array(4);
both[0]=1300; // calcium
both[1]=1500; //sodium low
both[2]=2300; //sodium high
both[3]=300; // cholesterol

var female=new Array(8);
female[0]="55"; //lowest normal fat
female[1]="78"; // highest normal fats
female[2]="22"; // saturated fats
female[3]="2000"; // calories
female[4]="46"; // protein
female[5]="15"; // iron
female[6]="2333"; // vitamin a
female[7]="23"; // fibre

var male=new Array(10);
male[0]="61"; // lowest total fats
male[1]="95"; // highest total fats
male[2]="24"; // lowest saturated fats
male[3]="27"; // hihgest saturated fats
male[4]="2200"; // lowest calories
male[5]="2400"; // highest calories
male[6]="52"; // protein
male[7]="11"; // iron
male[8]="3000"; // vitamin a
male[9]="32.5"; // fibre

//no more arrays, new variables to have values assigned to them so they can be calculated later on.
// these values will contain raw values that will be later assigned in the calculation stage.
var fats="null"; // normal fats
var sf="null"; // saturated fats
var cal="null"; // calories
var pro="null"; // protein
var iron="null"; // iron
var vita="null"; // vitamin A
var fibre="null"; // fibre
var sod="null"; // sodium

function check()
{
gender=document.dataform.gender.value;
age=document.dataform.age.value;
alert(gender+" "+age);
}

function test()
{
alert("works");
}
</script>
</head>
<body>
<h1 align="center">Application Programming</h1>
<hr>
<form name="dataform">
<table align="center" border="1" cellpadding="1" width="300px">
<tr>
<td colspan="2">Please select your age and gender</td>
</tr>
<tr>
<td align="right" width="148px">Age :</td>
<td align="left"><select name="age">
<option value="1"> </option>
<option value="14">14 Years Old</option>
<option value="15">15 Years Old</option>
<option value="16">16 Years Old</option>
<option value="17">17 Years Old</option>
<option value="18">18 Years Old</option>
</select>
</td>
</tr>
<tr>
<td align="right">Gender :</td>
<td align="left"><select name="gender">
<option value="2"> </option>
<option value="0">Female</option>
<option value="1">Male</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" value="Maths" onclick="test();"></td>
</tr>
</table>
</form>
</body>
</html>

vwphillips
10-07-2008, 10:44 AM
what is wrong with the arrays?

At the moment you are not using them.

german_89
10-08-2008, 12:48 AM
Is still not working ............ you can try to run the program, it does not show the message that I want.

Just try to run it and you will see what is wrong ........

Anyways Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum