javascript advice on forms
Posted: Tue Sep 20, 2005 11:58 am
Weirdan | Please use
Weirdan | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
can you pls tell me what i have done wrong here?
i want to add input1 and input2 together and then display it in the msgbox,
the strange thing is that it works when i want to subtract multiply and divide but not addCode: Select all
<script type="text/javascript">
function valid(form)
{
var input1=0;
var input2=0;
var tot = 0;
input1 = document.myform.data1.value;
input2 = document.myform.data2.value;
tot = input1 + input2;
alert("Hello " + tot + "! Welcome...");
}
</SCRIPT>
Click on the button after entering your
name into the text box:<BR>
<form name="myform">
<input type="text" name="data1" value="" size=10>
<input type="text" name="data2" value="" size=10>
<INPUT TYPE="button" VALUE="Click Here" onClick="valid(this.form)">
</form>Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]