0% found this document useful (0 votes)
104 views2 pages

Calc

This document contains code for a basic calculator application for mobile devices. It includes a form to input two numbers and select an operation, and uses JavaScript code to perform the calculation and display the result. The form allows entering values, selecting an operator, and clicking a button to call a function that will calculate the result and display it.

Uploaded by

Deepa Thilak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views2 pages

Calc

This document contains code for a basic calculator application for mobile devices. It includes a form to input two numbers and select an operation, and uses JavaScript code to perform the calculation and display the result. The form allows entering values, selecting an operator, and clicking a button to call a function that will calculate the result and display it.

Uploaded by

Deepa Thilak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

calc.

wml

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">

<wml>
<card id=”card1? title=”Calculator” newcontext=”true”>
<p><br/>
Value1: <input format="N*M" name="amount1" title=”First Amount:”/><br/>
Operator :<select name="operator" value="ADD" title=”Operation:”>
<option value="ADD">Addition</option>
<option value="SUB">Subtraction</option>
<option value="MULT">Multiplication</option>
<option value="DIV">Division</option>
</select><br/>
Value2:<input format="N*M" name="amount2" title=”Second Amount:”/>
<br/>
<do type="accept" label=”Result”>
<go href="calc.wmls#operation('answer',$(amount1),'$(operator)',$(amount2))"/>
</do>
Result : = <b>$(answer)</b>
</p>
</card>
</wml>

calc.wmls (save within double quotes)

extern function operation(result,val1,operate,val2)


{
var ans=0;
if (operate=='ADD')
{
ans = val1 + val2;
}
else if (operate=='SUB')
{
ans = val1 - val2;
}
else if (operate=='MULT')
{
ans = val1 * val2;
}
else
{
ans = val1 / val2;
}
WMLBrowser.setVar(result,ans);
WMLBrowser.go("calc.wml#result");
WMLBrowser.refresh();
}

OUTPUT

You might also like