Re: Problems retrieving data from form fields for non-encrypted host
Martin Honnen <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Organization | Liberty Development |
| Message-ID | <[email protected]> |
Siegfried Heintze wrote:
> So now I have these two edit boxes with the default values in them and when
> I click add, it adds correctly. However, if I try to change the numeric
> values in the edit boxes and then click add, it restores the default values
> and computes the same sum again. This is strange!
Well the code you posted does that intentionally, it has the following lines
var aa=322.33, bb=298.22;
document.main.a.value=""+aa; document.main.b.value=""+bb;
and that obviously has fixed values for aa and bb and assigns these
values as the content of the form control each time the add function is
called.
You probably want to give your function add two parameters e.g.
function add (a, b) {
...
}
and then in the form button you use
<input type="button" value="add"
onclick="add(this.form.elements.a.value,
this.form.elements.b.value);">
--
Martin Honnen
http://JavaScript.FAQTs.com/