Hi I’m trying to figure out how old a user is and how many hrs are spent playing video games a day to show how many yrs were spent playing video games. The formula would be years(hoursvideogames*age)divided by 24. I’ve done this before but not with the radio buttons and drop down list. How would I calculate this with the getelementbyID() method. So when they click submit it should write their name and how many years have been spend on the computer. I know I dont have any of the calculations, I didnt want to post them since they’re way off, could someone show me how to get started? I am going to put more age options but didn’t want to post all of them since it makes the code look massive.
<html>
<head>
<script type=’text/javascript’>
function check(browser)
{
document.getElementById(“answer”).value=browser;
}
<div>
function formValidator(){
// Make quick references to our fields
var firstname = document.getElementById(‘firstname’);
var myAge = document.getElementById(‘age’);
if(isAlphabet(firstname, “Please enter only letters for your name”)){
}
return false;
}
</script>
</head>
<body>
<form onsubmit=’return formValidator()’ >
First Name: <input type=’text’ id=’firstname’ /><br />
Age: <select id=’age’>
<option>Please Choose</option>
<OPTION VALUE=”0″>–
<OPTION VALUE=”1″>1
<OPTION VALUE=”2″>2
<OPTION VALUE=”3″>3
<OPTION VALUE=”4″>4
<OPTION VALUE=”5″>5
<OPTION VALUE=”6″>6
<OPTION VALUE=”7″>7
<OPTION VALUE=”8″>8
<OPTION VALUE=”9″>9
<OPTION VALUE=”10″>10
<OPTION VALUE=”11″>11
<OPTION VALUE=”12″>12
<OPTION VALUE=”13″>13
<OPTION VALUE=”14″>14
<OPTION VALUE=”15″>15
<OPTION VALUE=”16″>16
<OPTION VALUE=”17″>17
</select><br />
<br />How many times:<br />
<input type=”radio” name=”browser” onclick=”check(this.value)” value=”2″>2<br />
<input type=”radio” name=”browser” onclick=”check(this.value)” value=”3″>3<br />
<input type=”radio” name=”browser” onclick=”check(this.value)” value=”4″>4<br />
<br />
</div>
<input type=’submit’ value=’Hours spend playing video games?’ />
</form>
</form>
</body>
</html>