Click to See Complete Forum and Search --> : how do i add the value of 2 text boxes?


pelegk1
01-11-2004, 07:23 AM
i am sending to a function the object of 2 text box
(i am sendint the this value of each text box!)
when i do :
obj1.value+obj2.value i gt a text and not a value!
what odo?
thnaksin advance
peleg

Fang
01-11-2004, 07:29 AM
text box values are strings, convert them first. parseInt, paresFloat etc..

fredmv
01-11-2004, 07:54 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" />
<style type="text/css">
/*<![CDATA[*/
label { display: block; }
/*]]>*/
</style>
</head>
<body>
<form action="#">
<div>
<label for="n1">
Number 1:
</label>
<input type="text" id="n1" />
<label for="n2">
Number 2:
</label>
<input type="text" id="n2" />
<input type="button" value="Add" onclick="alert(Number(elements[0].value)+Number(elements[1].value));" />
</div>
</form>
</body>
</html>

pelegk1
01-12-2004, 12:59 AM
every one