Click to See Complete Forum and Search --> : help with javascript


Bryan Tuffin
01-06-2003, 07:09 AM
Can anyone help me with the following javascript. I am trying to get it to read numbers from the first message box to count1 and then print it out in the last box. This is a code test for me but I can not get it to work. I would appreciate any help. Thanks.









<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>

<Script language='javascript'>

function number_set() {
count1 = 0
count2 = 0
count1 = document.number1
count2 = document.number2
document.test = count1
}
</script>
</head>

<body>
<font size="5">
enter first number.</font><input name="number1" class="enter"><font size="5">enter second number.</font><input name="number2" class="enter">
<input type='button' value='set numbers' onclick='Javascript:number_set()' class='button'>
<input name="test">
</body>

</html>

Bryan Tuffin
01-06-2003, 08:45 AM
Thanks for the help. I tryed it out and it works.

Bryan Tuffin
01-07-2003, 02:48 AM
I am trying to add the numbers of two variables together as in 1000 + 4000 = 5000. But I keep geting 10004000. In the code below I ues count1x += add









<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>enter first number</title>

<Script language='javascript'>

var count1x = 0
var count2x = 0
var count1y = 0
var count2y = 0
var add = 4000
function number_set() {

count1x = document.forms.set_number.number1x.value;
count2x = document.forms.set_number.number2x.value;
count1y = document.forms.set_number.number1y.value;
count2y = document.forms.set_number.number2y.value;
count1x += add
document.forms.set_number.test.value = count1x
}
</script>
</head>

<body>
<form name="set_number">
<font size="5">enter first number. </font><font size="6" color="#FF0000">x</font><input name="number1x" size="20"><font size="5">enter
second number. </font><font size="6" color="#FF0000">x</font><input name="number2x" size="20">
<input type='reset'>
<p>
<font size="5">
enter first number. </font><font size="6" color="#FF0000">y</font><input name="number1y" size="20"><font size="5">enter second number.
</font><font size="6" color="#FF0000">y</font><input name="number2y" size="20">
<input type='button' value='set numbers' onclick='Javascript:number_set()'>
<input name="test" size="20">
</p>
</form>

</body>

</html>