Results 1 to 3 of 3
http://idgs.in/244502
  1. #1
    ovarz's Avatar
    Join Date
    Dec 2008
    Location
    ovarz.co.nf
    Posts
    2
    Points
    3.81
    Thanks: 73 / 146 / 94

    Default [need help] kalkulator pake javascript

    cuy
    numpang nanya
    buntu neh

    saya buat kalkulator sederhana
    ini code nya

    Spoiler untuk code :

    <head>
    <title>OvaRZ Calculator</title>
    </head>

    <table border="2" width="200" cellspacing="0" cellpadding="0" bgcolor="#000000"
    style="border-color:black" onClick="previouskey=event.srcElement.innerText">
    <tr>
    <td width="100%" bgcolor="#FFFFFF" id="result"
    style="font:bold 20px Verdana;color:black;text-align='right'">0</td>
    </tr>
    <tr>
    <td width="100%" valign="middle" align="center"><table border="0" width="100%"
    cellspacing="0" cellpadding="0" style="font:bold 20px Verdana;color:white">
    <tr>
    <td width="80%" align="center"><table border="1" width="100%" cellspacing="0"
    cellpadding="0" style="cursor:hand;font:bold 20px Verdana;color:white"
    onMouseover="if (event.srcElement.tagName=='TD')event.srcElement.s tyle.color='yellow'"
    onMouseout="event.srcElement.style.color='white'" onselectStart="return false"
    onClick="calculate()" height="82">
    <tr>
    <td width="25%" align="center" height="17">7</td>
    <td width="25%" align="center" height="17">8</td>
    <td width="25%" align="center" height="17">9</td>
    <td width="25%" align="center" height="17">/</td>
    </tr>
    <tr>
    <td width="25%" align="center" height="19">4</td>
    <td width="25%" align="center" height="19">5</td>
    <td width="25%" align="center" height="19">6</td>
    <td width="25%" align="center" height="19">*</td>
    </tr>
    <tr>
    <td width="25%" align="center" height="19">1</td>
    <td width="25%" align="center" height="19">2</td>
    <td width="25%" align="center" height="19">3</td>
    <td width="25%" align="center" height="19">-</td>
    </tr>
    <tr>
    <td width="25%" align="center" height="19">0</td>
    <td width="25%" align="center" height="19"
    onClick="pn();previouskey=1;event.cancelBubble=tru e">+/-</td>
    <td width="25%" align="center" height="19">.</td>
    <td width="25%" align="center" height="19">+</td>
    </tr>
    </table>
    </td>
    <td width="20%"><div align="left"><table border="1" width="100%" cellspacing="0"
    cellpadding="0">
    <tr>
    <td width="100%" style="cursor:hand;font:bold 20px Verdana;color:white;text-align:center"
    onClick="result.innerText=0;results=''">C</td>
    </tr>
    </table>
    </div><div align="left"><table border="1" width="100%" cellspacing="0" cellpadding="0"
    height="81">
    <tr>
    <td width="100%" style="cursor:hand;font:bold 32px Verdana;color:white;text-align:center"
    onMouseover="event.srcElement.style.color='yellow' "
    onMouseout="event.srcElement.style.color='white'" onClick="calculateresult()">=</td>
    </tr>
    </table>
    </div></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>


    <script language="JavaScript1.2">

    /*
    DHTML Calculator Script-
    © Dynamic Drive (www.dynamicdrive.com)
    For full source code, installation instructions,
    100's more DHTML scripts, and Terms Of
    Use, visit dynamicdrive.com
    */

    var results=''
    var previouskey=''
    var re=/(\/|\*|\+|-)/
    var re2=/(\/|\*|\+|-){2}$/
    var re3=/.+(\/|\*|\+|-).+/
    var re4=/\d|\./
    var re5=/^[^\/\*\+].+\d$/
    var re6=/\./

    function calculate(){
    if (event.srcElement.tagName=="TD"){
    if (event.srcElement.innerText.match(re4)&&previouske y=="=")
    results=''
    if (result.innerText.match(re3)&&event.srcElement.inn erText.match(re)){
    if (!results.match(re5)){
    result.innerText="Error!"
    return
    }
    results=eval(results)
    if (results.toString().length>=12&&results.toString() .match(re6))
    results=results.toString().substring(0,12)
    result.innerText=results
    }

    results+=event.srcElement.innerText
    if (results.match(re2))
    results=results.substring(0,results.length-2)+results.charAt(results.length-1)

    result.innerText=results
    }
    }

    function calculateresult(){
    if (!results.match(re5)){
    result.innerText="Error!"
    return
    }
    results=eval(results)
    if (results.toString().length>=12&&results.toString() .match(re6))
    results=results.toString().substring(0,12)
    result.innerText=results
    }



    function pn(){
    if (result.innerText.charAt(0)!='-')
    result.innerText=results='-'+result.innerText
    else if (result.innerText.charAt(0)=='-')
    result.innerText=results=result.innerText*(-1)
    }

    </script>


    <body>
    </body>
    </html>


    nah
    yang mau saya tanya gan
    klo mau masang fungsi floor() sama ceil() dimana nya ya
    jadi bisa otomatis dibulatin hasilnya (misal 0,7 jadi 1 atau 0,2 jadi 0)
    bingung gan
    tak ubek2 google ngga dapet2
    yang dapet yang pake menu
    bukan otomatis

  2. Hot Ad
  3. #2

    Join Date
    May 2008
    Location
    /proc/sys/kernel/randomize_va_space
    Posts
    875
    Points
    1,326.90
    Thanks: 0 / 13 / 8

    Default

    Quote Originally Posted by ovarz View Post
    cuy
    numpang nanya
    buntu neh

    saya buat kalkulator sederhana
    ini code nya

    Spoiler untuk code :

    <head>
    <title>OvaRZ Calculator</title>
    </head>

    <table border="2" width="200" cellspacing="0" cellpadding="0" bgcolor="#000000"
    style="border-color:black" onClick="previouskey=event.srcElement.innerText">
    <tr>
    <td width="100%" bgcolor="#FFFFFF" id="result"
    style="font:bold 20px Verdana;color:black;text-align='right'">0</td>
    </tr>
    <tr>
    <td width="100%" valign="middle" align="center"><table border="0" width="100%"
    cellspacing="0" cellpadding="0" style="font:bold 20px Verdana;color:white">
    <tr>
    <td width="80%" align="center"><table border="1" width="100%" cellspacing="0"
    cellpadding="0" style="cursor:hand;font:bold 20px Verdana;color:white"
    onMouseover="if (event.srcElement.tagName=='TD')event.srcElement.s tyle.color='yellow'"
    onMouseout="event.srcElement.style.color='white'" onselectStart="return false"
    onClick="calculate()" height="82">
    <tr>
    <td width="25%" align="center" height="17">7</td>
    <td width="25%" align="center" height="17">8</td>
    <td width="25%" align="center" height="17">9</td>
    <td width="25%" align="center" height="17">/</td>
    </tr>
    <tr>
    <td width="25%" align="center" height="19">4</td>
    <td width="25%" align="center" height="19">5</td>
    <td width="25%" align="center" height="19">6</td>
    <td width="25%" align="center" height="19">*</td>
    </tr>
    <tr>
    <td width="25%" align="center" height="19">1</td>
    <td width="25%" align="center" height="19">2</td>
    <td width="25%" align="center" height="19">3</td>
    <td width="25%" align="center" height="19">-</td>
    </tr>
    <tr>
    <td width="25%" align="center" height="19">0</td>
    <td width="25%" align="center" height="19"
    onClick="pn();previouskey=1;event.cancelBubble=tru e">+/-</td>
    <td width="25%" align="center" height="19">.</td>
    <td width="25%" align="center" height="19">+</td>
    </tr>
    </table>
    </td>
    <td width="20%"><div align="left"><table border="1" width="100%" cellspacing="0"
    cellpadding="0">
    <tr>
    <td width="100%" style="cursor:hand;font:bold 20px Verdana;color:white;text-align:center"
    onClick="result.innerText=0;results=''">C</td>
    </tr>
    </table>
    </div><div align="left"><table border="1" width="100%" cellspacing="0" cellpadding="0"
    height="81">
    <tr>
    <td width="100%" style="cursor:hand;font:bold 32px Verdana;color:white;text-align:center"
    onMouseover="event.srcElement.style.color='yellow' "
    onMouseout="event.srcElement.style.color='white'" onClick="calculateresult()">=</td>
    </tr>
    </table>
    </div></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>


    <script language="JavaScript1.2">

    /*
    DHTML Calculator Script-
    © Dynamic Drive (www.dynamicdrive.com)
    For full source code, installation instructions,
    100's more DHTML scripts, and Terms Of
    Use, visit dynamicdrive.com
    */

    var results=''
    var previouskey=''
    var re=/(\/|\*|\+|-)/
    var re2=/(\/|\*|\+|-){2}$/
    var re3=/.+(\/|\*|\+|-).+/
    var re4=/\d|\./
    var re5=/^[^\/\*\+].+\d$/
    var re6=/\./

    function calculate(){
    if (event.srcElement.tagName=="TD"){
    if (event.srcElement.innerText.match(re4)&&previouske y=="=")
    results=''
    if (result.innerText.match(re3)&&event.srcElement.inn erText.match(re)){
    if (!results.match(re5)){
    result.innerText="Error!"
    return
    }
    results=eval(results)
    if (results.toString().length>=12&&results.toString() .match(re6))
    results=results.toString().substring(0,12)
    result.innerText=results
    }

    results+=event.srcElement.innerText
    if (results.match(re2))
    results=results.substring(0,results.length-2)+results.charAt(results.length-1)

    result.innerText=results
    }
    }

    function calculateresult(){
    if (!results.match(re5)){
    result.innerText="Error!"
    return
    }
    results=eval(results)
    if (results.toString().length>=12&&results.toString() .match(re6))
    results=results.toString().substring(0,12)
    result.innerText=results
    }



    function pn(){
    if (result.innerText.charAt(0)!='-')
    result.innerText=results='-'+result.innerText
    else if (result.innerText.charAt(0)=='-')
    result.innerText=results=result.innerText*(-1)
    }

    </script>


    <body>
    </body>
    </html>


    nah
    yang mau saya tanya gan
    klo mau masang fungsi floor() sama ceil() dimana nya ya
    jadi bisa otomatis dibulatin hasilnya (misal 0,7 jadi 1 atau 0,2 jadi 0)
    bingung gan
    tak ubek2 google ngga dapet2
    yang dapet yang pake menu
    bukan otomatis
    kalo mau nambah fungsi masih di dalem tag <script></script> say contoh:

    ================================================== ==
    ...
    ...
    ...
    ...
    function calculateresult(){
    if (!results.match(re5)){
    result.innerText="Error!"
    return
    }
    results=eval(results)
    if (results.toString().length>=12&&results.toString() .match(re6))
    results=results.toString().substring(0,12)
    result.innerText=results
    }



    function pn(){
    if (result.innerText.charAt(0)!='-')
    result.innerText=results='-'+result.innerText
    else if (result.innerText.charAt(0)=='-')
    result.innerText=results=result.innerText*(-1)
    }


    function tambah_disini(){
    pernyataan-pernyataan
    }
    </script>


    <body>
    </body>
    </html>
    ================================================== ==


    yg gw tebelin disitu naro fungsi,. mau diatas jg gpp,. asal masih dalem tag <script>,<script>

    kalo gini salah:

    ================================================== ==
    ...
    ...
    ...
    ...
    function calculateresult(){
    if (!results.match(re5)){
    result.innerText="Error!"
    return
    }
    results=eval(results)
    if (results.toString().length>=12&&results.toString() .match(re6))
    results=results.toString().substring(0,12)
    result.innerText=results
    }



    function pn(){
    if (result.innerText.charAt(0)!='-')
    result.innerText=results='-'+result.innerText
    else if (result.innerText.charAt(0)=='-')
    result.innerText=results=result.innerText*(-1)
    }

    </script>

    function salah(){
    pernyataan-pernyataan
    }

    <body>
    </body>
    </html>
    ================================================== ==

    buat pernyataannya gampang lah ya,. mau dibuletin kan, dah kebayang pasti algonya smile:
    gut luck

  4. #3
    ovarz's Avatar
    Join Date
    Dec 2008
    Location
    ovarz.co.nf
    Posts
    2
    Points
    3.81
    Thanks: 73 / 146 / 94

    Default

    Quote Originally Posted by bl00d13z View Post
    kalo mau nambah fungsi masih di dalem tag <script></script> say contoh:

    ================================================== ==
    ...
    ...
    ...
    ...
    function calculateresult(){
    if (!results.match(re5)){
    result.innerText="Error!"
    return
    }
    results=eval(results)
    if (results.toString().length>=12&&results.toString() .match(re6))
    results=results.toString().substring(0,12)
    result.innerText=results
    }



    function pn(){
    if (result.innerText.charAt(0)!='-')
    result.innerText=results='-'+result.innerText
    else if (result.innerText.charAt(0)=='-')
    result.innerText=results=result.innerText*(-1)
    }


    function tambah_disini(){
    pernyataan-pernyataan
    }
    </script>


    <body>
    </body>
    </html>
    ================================================== ==


    yg gw tebelin disitu naro fungsi,. mau diatas jg gpp,. asal masih dalem tag <script>,<script>

    kalo gini salah:

    ================================================== ==
    ...
    ...
    ...
    ...
    function calculateresult(){
    if (!results.match(re5)){
    result.innerText="Error!"
    return
    }
    results=eval(results)
    if (results.toString().length>=12&&results.toString() .match(re6))
    results=results.toString().substring(0,12)
    result.innerText=results
    }



    function pn(){
    if (result.innerText.charAt(0)!='-')
    result.innerText=results='-'+result.innerText
    else if (result.innerText.charAt(0)=='-')
    result.innerText=results=result.innerText*(-1)
    }

    </script>

    function salah(){
    pernyataan-pernyataan
    }

    <body>
    </body>
    </html>
    ================================================== ==

    buat pernyataannya gampang lah ya,. mau dibuletin kan, dah kebayang pasti algonya smile:
    gut luck
    blom dapet kk
    tolong sekalian jawabannya deh kk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •