Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1

    Default need help html calculator....


    good day mga master...practice2 ko ... og himo og calculator sa htmlgalibog ko kung unsaon ni nga problem...if mag add kog numbers for ex. 2+4=6 nya ang 6 kay plusan nakog 2 (6+2 = then mo click ko sa '=' nga button ang display niya sa textbox as answer 10 niya og mo click pa gyud ko sa '=' nga button mahimo na siyang 12click nasad mahimo siyang 14 and so on....mao diay ni ako code mga master.. salamat


    HTML
    Code:
    <html>
    <title>Calculator</title>
    <head>
        <script type="text/javascript" charset="utf-8" src="js/cordova-1.9.0.js"></script>
        <style = "text/css">
            input.btn{
                width:68px;
                height:50px;
            }
            .txt{
                width:280;
                height:50;
                font-size:30;
            }
            font{
                font-size:40px;
                font-weight:bold;
            }
        </style>
        <!--<link rel="stylesheet" href="jquery/jquery.mobile-1.1.0.min.css" />
        <link rel="stylesheet" href="jquery/jquery.mobile-1.1.0.css" />
        <script src="jquery/jquery-1.1.0.min.js"></script>
        <script src="jquery/jquery-1.7.1.min.js"></script>-->
    </head>
    <body>
    <!--calculator-->
    <form name="calculator" action="">
    <table border=1 align="center" bgcolor="black">
    <tr>
    <td>
        <table border=1 align="center">
            <tr>
                <td>
                    <input type="text" id="box1" class="txt" size=20>
                </td>
            </tr>
        </table>
        
        <table align="center">
            <tr>
                <td>
                    <input type="button" name="clear" style="width:140px;height:50px;" class="btn" value=" C " onclick="Clear()">
                </td>
                <td>
                    <input type="button" name="delete" style="width:140px;height:50px;" class="btn" value=" Delete " onclick="Delete()">
                </td>
            </tr>
        </table>
        
        <table align="center">
            <tr>
                <td>
                    <input type="Button" data-role="button" name="seven" class="btn" value=" 7 " onclick="NumPressed(7)">
                </td>
                <td>
                    <input type="button" name="eight" class="btn" value=" 8 " onclick="NumPressed(8)">
                </td>
                <td>
                    <input type="button" name="nine" class="btn" value=" 9 " onclick="NumPressed(9)">
                </td>
                 <td>
                    <input type="button" name="divide" class="btn" value=" / " onclick="Operation('/')">
                </td>
            </tr>
            
            <tr>
                <td>
                    <input type="button" name="four" class="btn" value=" 4 " onclick="NumPressed(4)">
                </td>
                <td>
                    <input type="button" name="five" class="btn" value=" 5 " onclick="NumPressed(5)">
                </td>
                <td>
                    <input type="button" name="six" class="btn" value=" 6 " onclick="NumPressed(6)">
                </td>
                 <td>
                    <input type="button" name="multiply" class="btn" value=" * " onclick="Operation('*')">
                </td>
            </tr>   
            
             <tr>
                <td>
                    <input type="button" name="one" class="btn" value=" 1 " onclick="NumPressed(1)">
                </td>
                <td>
                    <input type="button" name="two" class="btn" value=" 2 " onclick="NumPressed(2)">
                </td>
                <td>
                    <input type="button" name="three" class="btn" value=" 3 " onclick="NumPressed(3)">
                </td>
                 <td>
                    <input type="button" name="subtract" class="btn" value=" - " onclick="Operation('-')">
                </td>
            </tr>
             <tr>
                <td>
                    <input type="button" name="zero" class="btn" value=" 0 " onclick="NumPressed(0)">
                </td>
                <td>
                    <input type="button" name="decimal" class="btn" value=" . " onclick="Decimal()">
                </td>
                <td>
                    <input type="button" name="equals" class="btn" value=" = " onclick="Operation('=')">
                <td>
                    <input type="button" name="add" class="btn" value=" + " onclick="Operation('+')">
                </td>
                </td>
            </tr>   
        </table>
    </td>
    </tr>
    </table>
    </form>
    <script type="text/javascript" src="js/operations.js">
        </script>
    </body>    
    </html>
    Javascript
    Code:
    
    	
    	var Calculator1 = document.calculator;
    	var Total = 0;
    	var FlagNewNum = false;
    	var PendingOperation = "";
    	
    	function NumPressed(Num) {
    		if (FlagNewNum) {
    			Calculator1.box1.value = Num;
    			FlagNewNum = false;
    		}
    	else {
    		if (Calculator1.box1.value == "0")
    			Calculator1.box1.value = Num;
    		else
    			Calculator1.box1.value += Num;
    		}
    	}
       
       function Operation(Op){
    		var newbox1 = Calculator1.box1.value;
    		FlagNewNum = true;
    		
    			if ( '+' == PendingOperation )
    				Total += parseFloat(newbox1);
    			else if ( '-' == PendingOperation )
    				Total -= parseFloat(newbox1);
    			else if ( '/' == PendingOperation )
    				Total /= parseFloat(newbox1);
    			else if ( '*' == PendingOperation )
    				Total *= parseFloat(newbox1);
    			else
    			{
    				Total = parseFloat(newbox1);
    				Calculator1.box1.value = Total
    			}
    				Calculator1.box1.value = Total;
    				PendingOperation = Op;	
    	}
    	
    	function Decimal () {
    			var curbox1 = Calculator1.box1.value;
    			if (FlagNewNum) {
    			curbox1 = "0.";
    			FlagNewNum = false;
    		}
    		else
    		{
    			if (curbox1.indexOf(".") == -1)
    			curbox1 += ".";
    		}
    			Calculator1.box1.value = curbox1;
    	}
    	
    	function Clear(){
    		Total = 0;
    		PendingOperation = 0;
    		Calculator1.box1.value = '';
    	}
    	
    	function Delete(){
    		Calculator1.box1.value = Calculator1.box1.value.substring(0,Calculator1.box1.value.length-1);
    	}

  2. #2

    Default Re: need help html calculator....

    Javascript file

    Code:
        
            var Total = 0;
        var FlagNewNum = false;
        var PendingOperation = "";
        
        function NumPressed(Num) {
            if (FlagNewNum) {
                document.getElementById("box1").value = Num;
                FlagNewNum = false;
            }else {
                if (document.getElementById("box1").value == "0"){
                    document.getElementById("box1").value = Num;
                }else{
                    document.getElementById("box1").value += Num;
                }
            }
        }
       
       function Operation(Op){
            var newbox1 = document.getElementById("box1").value;
            FlagNewNum = true;
            
                if ( '+' == PendingOperation )
                    Total += parseFloat(newbox1);
                else if ( '-' == PendingOperation )
                    Total -= parseFloat(newbox1);
                else if ( '/' == PendingOperation )
                    Total /= parseFloat(newbox1);
                else if ( '*' == PendingOperation )
                    Total *= parseFloat(newbox1);
                else
                {
                    Total = parseFloat(newbox1);
                    document.getElementById("box1").value = Total
                }
                    document.getElementById("box1").value = Total;
                    PendingOperation = Op;    
        }
        
        function Decimal () {
                var curbox1 = document.getElementById("box1").value;
                if (FlagNewNum) {
                curbox1 = "0.";
                FlagNewNum = false;
            }
            else
            {
                if (curbox1.indexOf(".") == -1)
                curbox1 += ".";
            }
                document.getElementById("box1").value = curbox1;
        }
        
        function Clear(){
            Total = 0;
            PendingOperation = 0;
            document.getElementById("box1").value = '';
        }
        
        function Delete(){
            Calculator1.box1.value = document.getElementById("box1").value.substring(0,document.getElementById("box1").value.length-1);
        }
    HTML File

    Code:
    <html>
    <title>Calculator</title>
    <head>
        <script type="text/javascript" charset="utf-8" src="js/cordova-1.9.0.js"></script>
        <style = "text/css">
            input.btn{
                width:68px;
                height:50px;
            }
            .txt{
                width:280;
                height:50;
                font-size:30;
            }
            font{
                font-size:40px;
                font-weight:bold;
            }
        </style>
        <!--<link rel="stylesheet" href="jquery/jquery.mobile-1.1.0.min.css" />
        <link rel="stylesheet" href="jquery/jquery.mobile-1.1.0.css" />
        <script src="jquery/jquery-1.1.0.min.js"></script>
        <script src="jquery/jquery-1.7.1.min.js"></script>-->
    </head>
    <body>
    <!--calculator-->
    <p id="Myvar">sdf</p>
    <form name="calculator" id="calculator" action="">
    <table border=1 align="center" bgcolor="black">
    <tr>
    <td>
        <table border=1 align="center">
            <tr>
                <td>
                    <input type="text" id="box1" class="txt" size=20>
                </td>
            </tr>
        </table>
        
        <table align="center">
            <tr>
                <td>
                    <input type="button" name="clear" style="width:140px;height:50px;" class="btn" value=" C " onClick="Clear()">
                </td>
                <td>
                    <input type="button" name="delete" style="width:140px;height:50px;" class="btn" value=" Delete " onClick="Delete()">
                </td>
            </tr>
        </table>
        
        <table align="center">
            <tr>
                <td>
                    <input type="Button" data-role="button" name="seven" class="btn" value=" 7 " onClick="NumPressed(7)">
                </td>
                <td>
                    <input type="button" name="eight" class="btn" value=" 8 " onClick="NumPressed(8)">
                </td>
                <td>
                    <input type="button" name="nine" class="btn" value=" 9 " onClick="NumPressed(9)">
                </td>
                 <td>
                    <input type="button" name="divide" class="btn" value=" / " onClick="Operation('/')">
                </td>
            </tr>
            
            <tr>
                <td>
                    <input type="button" name="four" class="btn" value=" 4 " onClick="NumPressed(4)">
                </td>
                <td>
                    <input type="button" name="five" class="btn" value=" 5 " onClick="NumPressed(5)">
                </td>
                <td>
                    <input type="button" name="six" class="btn" value=" 6 " onClick="NumPressed(6)">
                </td>
                 <td>
                    <input type="button" name="multiply" class="btn" value=" * " onClick="Operation('*')">
                </td>
            </tr>   
            
             <tr>
                <td>
                    <input type="button" name="one" class="btn" value=" 1 " onClick="NumPressed(1)">
                </td>
                <td>
                    <input type="button" name="two" class="btn" value="2" onClick="NumPressed(2)">
                </td>
                <td>
                    <input type="button" name="three" class="btn" value=" 3 " onClick="NumPressed(3)">
                </td>
                 <td>
                    <input type="button" name="subtract" class="btn" value=" - " onClick="Operation('-')">
                </td>
            </tr>
             <tr>
                <td>
                    <input type="button" name="zero" class="btn" value=" 0 " onClick="NumPressed(0)">
                </td>
                <td>
                    <input type="button" name="decimal" class="btn" value=" . " onClick="Decimal()">
                </td>
                <td>
                    <input type="button" name="equals" class="btn" value=" = " onClick="Operation('=')">
                <td>
                    <input type="button" name="add" class="btn" value=" + " onClick="Operation('+')">
                </td>
                </td>
            </tr>   
        </table>
    </td>
    </tr>
    </table>
    </form>
    </body>    
    </html>
    Try to use Chrome then right click on Page, choose Inspect Element, then click console..
    makit.an nimo ang errors didto..

    Wala ko naka try sa delete.. pero i-try lang og update..

  3. #3

    Default Re: need help html calculator....

    activity sa school haha

  4. #4

    Default Re: need help html calculator....

    d ghapon mo update sa answer inig click sa '=' nga button.. hehehhee .. salamat

  5. #5

    Default Re: need help html calculator....

    Quote Originally Posted by wongfeihong View Post
    d ghapon mo update sa answer inig click sa '=' nga button.. hehehhee .. salamat
    We'll give that task to you... you can do it bro..!

  6. #6

    Default Re: need help html calculator....

    Kataw-anan oi. Before pd ka mangayo ug tabang ba, suwayi pd ug sabot ang code na imong gi copya oi. Klaro kaayo nga dli imoha kay ang sa HTMl kay gi include tanan jquery, nya sa javascript kay wala juy jquery gigamit. Ka LOLz aning mga in-ani nga aspiring "developers" oi. Dli mn sa pag gara2x ba, pero programming is a discipline. You have to take it upon yourself to go out there and learn something. Not post in some forum and hope that some random stranger could complete your assignment.

    A calculator that takes basic arithmetic has to be one of the simplest programs you could make in any language. If you'd have taken the effort to post this question and put it into some smart Googling and serious reading, you'd have had your answer in an hour.

    The programming community /LOVES/ to help other programmers out, especially the newbies who are just testing the waters. We love to impart knowledge, experiences, tips, links and whatnot. What we don't like are people who post "need help.." threads without even the showing the slightest hint of effort. That just pisses us off. We hate having people like work for us, or worse, work _with_ us. God knows we've got these types in the workforce.

    In my opinion, kill this lazy mindset before it spreads.

    /rant
    /public-service

  7. #7
    Elite Member
    Join Date
    May 2011
    Gender
    Male
    Posts
    1,465

    Default Re: need help html calculator....

    murag taga dri nis amu skul dah kai calculator mai project nila. mao man sad sa akong mga kaila

  8. #8

    Default Re: need help html calculator....

    Quote Originally Posted by kamahak View Post
    Kataw-anan oi. Before pd ka mangayo ug tabang ba, suwayi pd ug sabot ang code na imong gi copya oi. Klaro kaayo nga dli imoha kay ang sa HTMl kay gi include tanan jquery, nya sa javascript kay wala juy jquery gigamit. Ka LOLz aning mga in-ani nga aspiring "developers" oi. Dli mn sa pag gara2x ba, pero programming is a discipline. You have to take it upon yourself to go out there and learn something. Not post in some forum and hope that some random stranger could complete your assignment.

    A calculator that takes basic arithmetic has to be one of the simplest programs you could make in any language. If you'd have taken the effort to post this question and put it into some smart Googling and serious reading, you'd have had your answer in an hour.

    The programming community /LOVES/ to help other programmers out, especially the newbies who are just testing the waters. We love to impart knowledge, experiences, tips, links and whatnot. What we don't like are people who post "need help.." threads without even the showing the slightest hint of effort. That just pisses us off. We hate having people like work for us, or worse, work _with_ us. God knows we've got these types in the workforce.

    In my opinion, kill this lazy mindset before it spreads.

    /rant
    /public-service

    ang kanang jquery diha para na sa android..niya mogana rana sa emulator kay jquery for mobile raman na siya.. mao naakong gi comment....gisabot na ko na ako codes....

    wa man ko nangayo og codes ang ako lang unta nga makakuha kog ideas kung unsaon....

    nasolve nasad nako kung unsaon.... salamat sa reply....

  9. #9

    Default Re: need help html calculator....

    Quote Originally Posted by wongfeihong View Post
    d ghapon mo update sa answer inig click sa '=' nga button.. hehehhee .. salamat
    nangutana akong amigo ts if ok na bah ni? if wala pa daghan daw paagi.. ingon sya ang usa daw kay store nimo ang previous operation na dili '=' sunod perform previous operation if ma click ang '=' run daw ang previous operation against ang total ug ang value sa new box..

    wala ko kasabot sa akong gi type pero mao ingon niya..

  10. #10

    Default Re: need help html calculator....

    Quote Originally Posted by wongfeihong View Post
    ang kanang jquery diha para na sa android..niya mogana rana sa emulator kay jquery for mobile raman na siya.. mao naakong gi comment....gisabot na ko na ako codes....

    wa man ko nangayo og codes ang ako lang unta nga makakuha kog ideas kung unsaon....

    nasolve nasad nako kung unsaon.... salamat sa reply....
    TS: Kay naka include naman nang jquery dha why not use it nalang sakto si kamahak sabta kung unsay gamit sa jquery mo lessen pa na imong javascript code ug masabtan nimo ang jquery

    @kamahak: sakto imo sulti but yaw kasab.e ang TS ky dili na motuo nmo ug kasab.an nimo taronga lang pd ug pagsabot
    Last edited by prokops; 07-18-2012 at 01:55 PM.

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. I need help from HTML tags
    By mr_kyme in forum Websites & Multimedia
    Replies: 6
    Last Post: 12-19-2007, 09:15 PM
  2. Need HELP with aikelyu.html and others!!
    By Maverick007 in forum Software & Games (Old)
    Replies: 9
    Last Post: 10-01-2007, 11:55 PM
  3. MOVED: Need HELP with aikelyu.html and others!!
    By diem in forum Computer Hardware
    Replies: 0
    Last Post: 09-18-2007, 06:21 AM
  4. needs help on HTML
    By tagaisla in forum Websites & Multimedia
    Replies: 11
    Last Post: 11-16-2005, 03:32 AM
  5. MOVED: needs help on HTML
    By vern in forum Networking & Internet
    Replies: 0
    Last Post: 11-14-2005, 04:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top