Computing.Net > Forums > Programming > Forms arithmetic

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Forms arithmetic

Reply to Message Icon

Name: Larry
Date: October 14, 2003 at 20:23:11 Pacific
OS: XP Home
CPU/Ram: PIII 386MB
Comment:

Is there a way to add a column of number fields up in an HTML form? Would like to do using HTML, Javascript or Java applet that is already written.




Sponsored Link
Ads by Google

Response Number 1
Name: Dr. Nick
Date: October 14, 2003 at 23:59:59 Pacific
Reply:

Some quick Javascript would be easiest. Just add this in the <head> tag of your page:

<script>

function add()
{
  form.total.value =
  parseInt(form.input1.value) +
  parseInt(form.input2.value) +
  parseInt(form.input3.value);
}

</script>

Here's my code for my form:

<form name="form">

<input type="text" name="input1">[br]
<input type="text" name="input2">[br]
<input type="text" name="input3">[br]
----------------[br]
<input type="text" name="total">[p]

<input type="button" value="Add" onClick="javascript:add();">

</form>

You'll need to change the Javascript code to match your form name and input names. I've used 'form' as my form name and 'input#' as my input fields' names. Note also that I've used [ and ] instead of < and > so that some tags will be displayed right.



0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Forms arithmetic

How do I hide a form on load vb.net www.computing.net/answers/programming/how-do-i-hide-a-form-on-load-vbnet/4597.html

access 2003 form fetch www.computing.net/answers/programming/access-2003-form-fetch/12617.html

HTML Automatic Form Execution www.computing.net/answers/programming/html-automatic-form-execution/1490.html