www.webdeveloper.com
Results 1 to 3 of 3

Thread: What is the function codes for "IF"?

  1. #1
    Join Date
    Sep 2003
    Posts
    47

    What is the function codes for "IF"?

    **Note sign ">" means greater than.


    IF "GRT" > 40000, "Port dues" will show result 175,
    IF "GRT" > 20000, "Port dues" will show result 140,
    IF "GRT" > 10000, "Port dues" will show result 105,
    IF "GRT" > 5000, "Port dues" will show result 80,
    IF "GRT" > 2000, "Port dues" will show result 60,
    IF "GRT" > 1000, "Port dues" will show result 40,
    IF "GRT" > 75, "Port dues" will show result 25


    Link: http://www.oceanbulk.com.sg/maths.html

  2. #2
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    Hi!

    function calcValue(){
    dues=document.getElementById('j');
    val=Number(getEl('a').value);
    if(val>40000)dues.value=175
    else if(val>20000)dues.value=140
    else if(val>10000)dues.value=105
    else if(val>5000)dues.value=80
    else if(val>2000)dues.value=60
    else if(val>1000)dues.value=40
    else if(val>75)dues.value=25
    document.getElementById('total').value = Number(getEl('a').value) + Number(getEl('b').value) + Number(getEl('c').value) + Number(getEl('d').value) + Number(getEl('e').value) + Number(getEl('f').value) + Number(getEl('g').value) + Number(getEl('g').value) + Number(getEl('i').value) + Number(getEl('j').value) + Number(getEl('k').value) + Number(getEl('l').value);
    }

    Cheers - Pit

  3. #3
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    Hi!

    In reply to your pm:
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    title>AGENCY PROFORMA FOR VESSEL CALL SINGAPORE FOR BUNKERING AT ANCHORAGE::MARS Shipping Trading</title>
    <
    meta http-equiv="content-type" content="text/html; charset=utf-8">
    <
    style type="text/css">
    fieldset padding1em }
    </
    style>
    <
    script type="text/javascript">
    function 
    bindEvents(){
    for(
    i=0i<arguments.lengthi++){
    arguments[i].onkeydown calcValue;
    arguments[i].onkeyup calcValue;
    }
    }
    function 
    getEl(id) { return document.getElementById(id) }
    function 
    calcValue(){
    document.getElementById('j').value Number(getEl('a').value) / 100;
    dues=document.getElementById('k');
    val=Number(getEl('a').value);
    if(
    val>40000)dues.value=175
    else if(val>20000)dues.value=140
    else if(val>10000)dues.value=105
    else if(val>5000)dues.value=80
    else if(val>2000)dues.value=60
    else if(val>1000)dues.value=40
    else if(val>75)dues.value=25
    else if(val<=75)dues.value=0//do not know, if you need this
    document.getElementById('total').value Number(getEl('a').value) + Number(getEl('b').value) + Number(getEl('c').value) + Number(getEl('d').value) + Number(getEl('e').value) + Number(getEl('f').value) + Number(getEl('g').value) + Number(getEl('g').value) + Number(getEl('i').value) + Number(getEl('j').value) + Number(getEl('k').value) + Number(getEl('l').value);
    }
    onload = function(){
    bindEvents(getEl('a'), getEl('b'), getEl('c'), getEl('d'), getEl('e'), getEl('f'), getEl('g'), getEl('h'), getEl('i'), getEl('j'), getEl('k'), getEl('l'));
    }
    </script>
    </head>
    <body>
    <form action="#">
    <fieldset>
    <legend>AGENCY PROFORMA FOR VESSEL CALL SINGAPORE FOR BUNKERING AT ANCHORAGE</legend>
    <dl>
    <dt><label for="a">GRT:</label></dt>
    <dd><input type="text" id="a"></dd>
    <dt><label for="b">Agency fee for first 48 hours</label></dt>
    <dd><input type="text" id="b"></dd>
    <dt><label for="c">Every subsequent day after 48 hours</label></dt>
    <dd><input type="text" id="c"></dd>
    <dt><label for="d">TLX/Fax/Ship call</label></dd>
    <dd><input type="text" id="d"></label></dd>
    <dt><label for="e">Agent transport fee</label></dt>
    <dd><input type="text" id="e"></label></dd>
    <dt><label for="f">Crew change (excluding transport/hotel/boat chanrge — if any)</label></dd>
    <dd><input type="text" id="f"></dd>
    <dt><label for="g">Agency service boat</label></dt>
    <dd><input type="text" id="g"></dd>
    <dt><label for="h">Cash to master expenses</label></dt>
    <dd><input type="text" id="h"></dd>
    <dt><label for="i">DOCUMENT & SPARE PARTS</label></dt>
    <dd><input type="text" id="i"></dd>
    <dt><label for="j">PORT DUES FOR FIRST 24 HRS</label></dt>
    <dd><input type="text" id="j"></dd> <font color=red><b>This is the one...</b></font>
    <dt><label for="k">NMB FEE</label></dt>
    <dd><input type="text" id="k"></dd>
    <dt><label for="l">PILOTAGE IN / OUT</label></dt>
    <dd><input type="text" id="l"></dd>
    </dl>
    <hr>
    <label for="total">Total:</label>
    <input type="text" id="total" value="0">
    <input type="reset">
    <INPUT TYPE="button" VALUE=" Print Page " onclick="javascript:window.print()">
    </fieldset>
    </form>
    </body>
    </html> 
    Was it that, what you need??

    Cheers - Pit

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles