+ Start a Discussion
Vivek ChaudhariVivek Chaudhari 

I am trying to write a calculator program with single inputtext. how it is possible please suggest?

ManojjenaManojjena
Hi Vivek,

Try with below code it wil help !!
<apex:page >
	<form Name="Calc">
		<TABLE BORDER="4">
			<TR>
				<TD>
					<INPUT TYPE="text"   NAME="Input" Size="16"/>MANOJ
					<br/>
				</TD>
			</TR>
			<TR>
				<TD>
					<INPUT TYPE="button" NAME="one"   VALUE="  1  " OnClick="Calc.Input.value += '1'"/>
					<INPUT TYPE="button" NAME="two"   VALUE="  2  " OnCLick="Calc.Input.value += '2'"/>
					<INPUT TYPE="button" NAME="three" VALUE="  3  " OnClick="Calc.Input.value += '3'"/>
					<INPUT TYPE="button" NAME="plus"  VALUE="  +  " OnClick="Calc.Input.value += ' + '"/>
					<br/>
					<INPUT TYPE="button" NAME="four"  VALUE="  4  " OnClick="Calc.Input.value += '4'"/>
					<INPUT TYPE="button" NAME="five"  VALUE="  5  " OnCLick="Calc.Input.value += '5'"/>
					<INPUT TYPE="button" NAME="six"   VALUE="  6  " OnClick="Calc.Input.value += '6'"/>
					<INPUT TYPE="button" NAME="minus" VALUE="  -  " OnClick="Calc.Input.value += ' - '"/>
					<br/>
					<INPUT TYPE="button" NAME="seven" VALUE="  7  " OnClick="Calc.Input.value += '7'"/>
					<INPUT TYPE="button" NAME="eight" VALUE="  8  " OnCLick="Calc.Input.value += '8'"/>
					<INPUT TYPE="button" NAME="nine"  VALUE="  9  " OnClick="Calc.Input.value += '9'"/>
					<INPUT TYPE="button" NAME="times" VALUE="  x  " OnClick="Calc.Input.value += ' * '"/>
					<br/>
					<INPUT TYPE="button" NAME="clear" VALUE="  c  " OnClick="Calc.Input.value = ''"/>
					<INPUT TYPE="button" NAME="zero"  VALUE="  0  " OnClick="Calc.Input.value += '0'"/>
					<INPUT TYPE="button" NAME="DoIt"  VALUE="  =  " OnClick="Calc.Input.value = eval(Calc.Input.value)"/>
					<INPUT TYPE="button" NAME="div"   VALUE="  /  " OnClick="Calc.Input.value += ' / '"/>
					<br/>
				</TD>
			</TR>
		</TABLE>
	</form>
</apex:page>

Let me know if it helps !!
Thanks 
Manoj
Vivek ChaudhariVivek Chaudhari
Thanks for Help..
Its working...
 
The SFDC MatrixThe SFDC Matrix
Hi Manaoj,
please tell can be possible with

<apex:inputText value="somevalue" action ="{!action}"/>
Thanks
Reply
ManojjenaManojjena
Hi SFDC Matrix,

You can call class method onclick of input text indirectly as action attribute is not there .

Try like below .
 
<apex:inputText value="{!inputValue}" id="theTextInput" onclick="doCall()"/>
<apex:actionFunction name="doCall" action="{!doSomething}" reRender="someid" />
Let me know if it helps !!

Try to open a new thread for new query if one else have doubt like this he/she can search and find eaisly .