Javascript conversion code

Hi all,

   First of all thanks for everyone who responds to me. I appreciate it.

Here is my problem.

I have a HTML form containing two text box controls in it and a submit button. When a user enters information in those two textboxes and click on submit, the information is sent to a function in Javascript. In the javascript, the information from those textboxes is stored in a javascript variable.

The problem is as follows:

When I am inputting string text in the html text boxes and in the javascript when I am trying to print those values, it is giving me out an error saying NaN. However when i input integer values in the text boxes it is printing those numbers. Is there a conversion that I have to do for the string to be printed. I am new to Javascript and need your help. This is a basic code of Javascript. Below is the code that I have. Thanks in advance for your help.

<html>
<script type = “text/javascript”>

function square(form)
{

var test = form.value1.value;
window.alert(+test);

var point = document.test.value1.value;
pointcon = point.toString();

window.alert(“nice”);
window.alert(+pointcon);

var point2 = eval(document.test.value2.value);

var point3 = point + point2;
alert(point3);

}

</script>

<head>
<body>
<form name = “test”>
First name: <input type=“text” name = “value1” value1 = “”/><br />
Last name: <input type=“text” name = “value2” value2 = “”/>
<input type = “button” value = “Submit” onClick=“square(this.form)”/>
</form>
</body>

</html>

Don’t use eval for this purpose. Use Number, parseInt or parseFloat: https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Functions#parseInt_and_parseFloat_Functions
Also remove the plus from in the alert argument

window.alert([COLOR="Red"]+[/COLOR]test);

Here is an example of the sort of code that you could be using instead:


var test = document.getElementById('test'),
    value1 = test.elements.value1.value,
    value2 = test.elements.value2.value,
    point = Number(value1),
    point2 = Number(value2),
    point3 = point + point2;
alert(point3);