English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to calculate blood alcohol with three input area in a form (number of drinks, number of hours, and weight) which then figures out the blood level of the person. I don't know how to make the output show.

2007-04-10 08:21:43 · 3 answers · asked by 3nathn 3 in Computers & Internet Programming & Design

3 answers

You write it as javascript. The javascript has a function that collects all the form box contents, does the math and puts the result into another document object of your design -- such as a textarea, a div. Several approaches to do this. Suppose you have 3 entry boxes on a form named Q1 ... Q3

function validate_form() {

a = document.form.Q1.value;
b = document.form.Q2.value;
c = document.form.Q3.value;
total = a + b + c;

alert ("Total = " + total);

}
on the html page you have a button. The button has a function call like this:

Probably the easiest way would be to write a PHP script on the server which would read the input fields entered on the form, then re-display the form with the results entered and the computation results displayed.

2007-04-10 15:28:43 · answer #2 · answered by fjpoblam 7 · 1 0

HTML does not have the capability to do this. You need a scripting language like Javascript, Perl, or PHP to do it.

2007-04-10 15:26:58 · answer #3 · answered by jkurrle 2 · 1 0

fedest.com, questions and answers