<script type="text/javascript">
var oLabel1 = new sap.ui.commons.Label("l1");
oLabel1.setText("Number1");
oLabel1.placeAt("content");
var oInput1 = new sap.ui.commons.TextField('input1');
//oInput1.setValue("Some Text");
oInput1.setTooltip("Input Positive number1");
//oInput1.attachChange(function(){alert('Text changed to :'+ oInput1.getValue());})
oInput1.placeAt("content");
var oLabel2 = new sap.ui.commons.Label("l2");
oLabel2.setText("Number2");
oLabel2.placeAt("content1");
var oInput2 = new sap.ui.commons.TextField('input2');
//oInput1.setValue("Some Text");
oInput2.setTooltip("Input Positive Number2");
//oInput1.attachChange(function(){alert('Text changed to :'+ oInput1.getValue());})
oInput2.placeAt("content1");
var oLabel3 = new sap.ui.commons.Label("l3");
oLabel3.setText("Result");
oLabel3.placeAt("content2");
var oInput3 = new sap.ui.commons.TextField('Result');
//oInput1.setValue("Some Text");
oInput3.setTooltip("Result");
//oInput1.attachChange(function(){alert('Text changed to :'+ oInput1.getValue());})
oInput3.placeAt("content2");
var myButton1=new sap.ui.commons.Button({
text:"Add",
style:sap.ui.commons.ButtonStyle.Emph,
//icon : "C:/Users/MM0387/Pictures/venu.png",
//"Alert from SAP UI5 First Program " +myButton.getText());
press:function()
{
var oTF1 = sap.ui.getCore().getElementById("input1").getValue();
var oTF2 = sap.ui.getCore().getElementById("input2").getValue();
if(oTF1<0 || oTF2<0)
alert("Enter only Positive Numbers");
else
var oTF3 = sap.ui.getCore().getElementById("Result");
oTF3.setValue(+oTF1 + +oTF2);
}
}).placeAt("content3");
// myButton.attachPress(oController.handleButtonClicked);
var myButton2=new sap.ui.commons.Button({
text:"Subtract",
style:sap.ui.commons.ButtonStyle.Emph,
//icon : "C:/Users/MM0387/Pictures/venu.png",
//"Alert from SAP UI5 First Program " +myButton.getText());
press:function()
{
var oTF1 = sap.ui.getCore().getElementById("input1").getValue();
var oTF2 = sap.ui.getCore().getElementById("input2").getValue();
if(oTF1<0 || oTF2<0)
alert("Enter only Positive Numbers");
else
var oTF3 = sap.ui.getCore().getElementById("Result");
oTF3.setValue(+oTF1 - +oTF2);
}
}).placeAt("content3");
var myButton3=new sap.ui.commons.Button({
text:"Divide",
style:sap.ui.commons.ButtonStyle.Emph,
//icon : "C:/Users/MM0387/Pictures/venu.png",
//"Alert from SAP UI5 First Program " +myButton.getText());
press:function()
{
var oTF1 = sap.ui.getCore().getElementById("input1").getValue();
var oTF2 = sap.ui.getCore().getElementById("input2").getValue();
if(oTF1<0 || oTF2<0)
alert("Enter only Positive Numbers");
else
var oTF3 = sap.ui.getCore().getElementById("Result");
oTF3.setValue(+oTF1 / +oTF2);
}
}).placeAt("content3");
var myButton4=new sap.ui.commons.Button({
text:"Multiply",
style:sap.ui.commons.ButtonStyle.Emph,
//icon : "C:/Users/MM0387/Pictures/venu.png",
//"Alert from SAP UI5 First Program " +myButton.getText());
press:function()
{
var oTF1 = sap.ui.getCore().getElementById("input1").getValue();
var oTF2 = sap.ui.getCore().getElementById("input2").getValue();
if(oTF1<0 || oTF2<0)
alert("Enter only Positive Numbers");
else
var oTF3 = sap.ui.getCore().getElementById("Result");
oTF3.setValue(+oTF1 * +oTF2);
}
}).placeAt("content3");
myButton1.setTooltip("Adds the values of Number1 & Number2");
myButton2.setTooltip("Subtracts the value from Number1 & Number2");
myButton3.setTooltip("Divides the value from Number1 & Number2");
myButton4.setTooltip("Provides the Product value of Number1 & Number2");
</script>