Hi I am new to React and js.
I am trying to write two text boxes such that the user will insert two numbers and when clicking Add button, he will get the result.
My suggestion was:
import React, { Component } from 'react';
export class Home extends Component {
displayName = Home.name
render() {
return (
<div>
<h1>Hello world! This is a new Web App</h1>
<input type="text" name="" id="txt1" />
+
<input type="text" name="" id="txt1" />
= <br/>
<button onClick="add()">Add</button>
</div>
);
}
}
And I thought and a function add() that will do the following:
function add()
{
var a = getElementById("txt1").value;
var b = getElementById("txt2").value;
alert(pardeInt(a)+parseInt(b));
}
If someone could edit my suggested code so it will work, that would be great.
Thanks in advance.