| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 703 人关注过本帖
标题:怎么用 Javascript 编写一个网页版计数器
只看楼主 加入收藏
江潮
Rank: 2
来 自:贵州
等 级:论坛游民
帖 子:33
专家分:27
注 册:2014-5-20
结帖率:72.73%
收藏
 问题点数:0 回复次数:2 
怎么用 Javascript 编写一个网页版计数器
用Javascript 编写一个网业计数器写到一半就写不下去了 谁会啊?
搜索更多相关主题的帖子: 计数器 网页 
2014-10-31 09:54
江潮
Rank: 2
来 自:贵州
等 级:论坛游民
帖 子:33
专家分:27
注 册:2014-5-20
收藏
得分:0 
//调用数字进行判断是否是数字和运算符
    function getnumber(shuzi)
    {
        if(document.getElementById("text").value!="0"){   
                if(isNum){//是数字
                    document.getElementById("text").value=document.getElementById("text").value+shuzi;
                }
                else{//是运算符
                    document.getElementById("text").value="";
                    document.getElementById("text").value=shuzi;
                    isYsfu=true;
                }
            
            }
        else{
                document.getElementById("text").value=shuzi;
                        }
            if (clickFuhao!="no")//如果点击了运算符
                {
                number2=document.getElementById("text").value;//保存第二次值
   
                    }
                    
        }

后面就不知道怎么写了

编程改变人生!编程改变世界!编程改变未来!
2014-10-31 10:11
JonasZhang
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-11-11
收藏
得分:0 
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. <title>网页版计算器</title>
    <script language="VBSCRIPT"> 
Function Show(m) 
If (Myform.Expression.Value = "" AND InStr(". + - * / ",m)) Then 
Myform.Expression.Value = "" 
ElseIf (InStr("+ - * / . ",Right(Myform.Expression.Value,1)) And InStr("+ - * / ",m)) Then 
ElseIf (m = ".") Then 
If (InStr("+ - * / . ",Right(Myform.Expression.Value,1))) Then 
ElseIf ((InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"+")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"-")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"*")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"/"))) Then 
Else 
Myform.Expression.Value = Myform.Expression.Value + m 
End If 
Else 
Myform.Expression.Value = Myform.Expression.Value + m 
END If 

End Function 

Function Sqrt() 
If (Myform.Expression.Value = "") Then 
Myform.Expression.Value = "" 
ElseIf (InStr(". + - * / ",Right(Myform.Expression.Value,1))) Then 
Else 
Myform.Expression.Value = Eval(Myform.Expression.Value)^2 
End If 

End Function 
Function Result() 
If (Myform.Expression.Value = "") Then 
Myform.Expression.Value = "" 
ElseIf (InStr(". + - * / ",Right(Myform.Expression.Value,1))) Then 
Else 
Myform.Expression.Value = Eval(Myform.Expression.Value) 
End If 
End Function 
Function Clean() 
Myform.Expression.Value = "" 
End Function 
    </script>
    <style type="text/css"> 
<!-- 
.style5 {font-size: 18px} 
--> 
</style>
</head>
<body bgcolor="#ffffee" text="#000000">
    <form name="myform" method="post" action="">
    <div align="center">
        <table bgcolor="#C0e0ff" width="214" height="245" border="4">
            <tr>
                <th width="206" scope="col">
                    <h2>
                        <font color="#0000A0">计算器 </font>
                    </h2>
                </th>
            </tr>
            <tr>
                <th height="36" scope="col">
                    <table width="200" border="1">
                        <tr>
                            <td colspan="4">
                                <div align="center">
                                    <input name="expression" type="text" value="" size="28" maxlength="28">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div align="center">
                                    <input type="button" id="seven" onclick="Show('7')" value=" 7 ">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" 8 " onclick="Show('8')">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" 9 " onclick="Show('9')">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" / " onclick="Show('/')">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div align="center">
                                    <input type="button" value=" 4 " onclick="Show('4')">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" 5 " onclick="Show('5')">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" 6 " onclick="Show('6')">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" * " onclick="Show('*')">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div align="center">
                                    <input type="button" value=" 1 " onclick="Show('1')">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" 2 " onclick="Show('2')">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" 3 " onclick="Show('3')">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" - " onclick="Show('-')">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div align="center">
                                    <input type="button" value=" 0 " onclick="Show('0')">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" . " onclick="Show('.')">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value="sqr" onclick="sqrt()">
                                </div>
                            </td>
                            <td>
                                <div align="center">
                                    <input type="button" value=" + " onclick="Show('+')">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <div align="center">
                                    <input type="button" value=" AC " onclick="clean()">
                                </div>
                            </td>
                            <td colspan="2">
                                <div align="center">
                                    <input type="button" value=" = " onclick="result()">
                                </div>
                            </td>
                        </tr>
                    </table>
                </th>
            </tr>
        </table>
        <script type="text/javascript">
            var op = window.dialogArguments;
            alert("你滴参数" + op);
        
        </script>
2014-11-11 09:41
快速回复:怎么用 Javascript 编写一个网页版计数器
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.045198 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved