开发者

how can i call this javascript calculator?

开发者 https://www.devze.com 2023-01-04 18:19 出处:网络
i hav this javascript code but the problem is that i am not able to call the html body part at client side in asp.net c#.so how can i call this javascript calculator when i click the button.

i hav this javascript code but the problem is that i am not able to call the html body part at client side in asp.net c#.so how can i call this javascript calculator when i click the button.

<script language="javascript">
var inputstring=" "
function updatestring(value)
{
    inputstring += value;
    document.calculator.input.value=inputstring;
}
</script>

<body bgcolor="white" topmargin="80">
<center>
<table border=5 bordercolor=black  cellspacing=8>
<form name="calculator">
<th>
THE CALCULATOR
</th>
<tr align="center">
<td>
<input type="text" name="input" maxlength=10 size=24>
</td></tr>
<tr align="center"><td>
    <input type="button" value="  +  " onclick="updatestring('+')">
    <input type="button" value="  -  " onclick="updatestring('-')">
    <input type="button" value="  /  " onclick="updatestring('/')">
    <input type="button" value="  *  " onclick="updatestring('*')">
</td></tr><tr align=center><td>
        <input type="button" value="  mod  " onclick="updatestring('%')">
        <input type="button" value="  0  " onclick="updatestring('0')"开发者_开发百科>
        <input type="button" value="  1  " onclick="updatestring('1')">
        <input type="button" value="  2  " onclick="updatestring('2')">
</td</tr><tr align=center><td>
            <input type="button" value="  3  " onclick="updatestring('3')">
            <input type="button" value="  4  " onclick="updatestring('4')">
            <input type="button" value="  5  " onclick="updatestring('5')">
            <input type="button" value="  6  " onclick="updatestring('6')">
</td></tr><tr align="center"><td>
                <input type="button" value="  7  " onclick="updatestring('7')">
                <input type="button" value="  8  " onclick="updatestring('8')">
                <input type="button" value="  9  " onclick="updatestring('9')">
</td></tr>
<tr align="center"><td>
                    <input type="button" value="  clear  " onclick="input.value=' ';inputstring=' ' ">
                        <input type="button" value="  =  " onclick="input.value=eval(inputstring);">
</td>
</tr>
</form>
</table>

my button code is like this:

<asp:Button ID="BtnCalc" runat="server" Text="Calculator" OnClick="BtnSave_Click" />


For ASP.NET Server Controls (such as the asp:Button server control),

OnClick delegates the click event to a server-side event handler.

Use OnClientClick to call client-side event handlers.

E.g

<asp:Button ID="BtnCalc" runat="server" Text="Calculator" OnClientClick="updateString(1)" />
0

精彩评论

暂无评论...
验证码 换一张
取 消