/    Sign up×
Community /Pin to ProfileBookmark

the functions doesn’t work…

Inputs on any of the boxes doesn’t reflects onto the “Total”? ?

[url]http://www.oceanbulk.com.sg/maths.html[/url]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@fredmvJul 23.2004 — <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style type="text/css">
fieldset { padding: 1em }
</style>
<script type="text/javascript">
function bindEvents()
{
for(i=0; i<arguments.length; i++)
{
arguments[i].onkeydown = calcValue;
arguments[i].onkeyup = calcValue;
}
}

<i> </i> function getEl(id) { return document.getElementById(id) }

<i> </i> function calcValue()
<i> </i> {
<i> </i> 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);
<i> </i> }

<i> </i> onload = function()
<i> </i> {
<i> </i> bindEvents(getEl('a'), getEl('b'), getEl('c'), getEl('d'), getEl('f'), getEl('g'));
<i> </i> }
<i> </i> &lt;/script&gt;
<i> </i>&lt;/head&gt;
<i> </i>&lt;body&gt;
<i> </i> &lt;form action="#"&gt;
<i> </i> &lt;fieldset&gt;
<i> </i> &lt;legend&gt;Calculation&lt;/legend&gt;
<i> </i> &lt;dl&gt;
<i> </i> &lt;dt&gt;&lt;label for="a"&gt;Agency fee; first 48 hours&lt;/label&gt;&lt;/dt&gt;
<i> </i> &lt;dd&gt;&lt;input type="text" id="a"&gt;&lt;/dd&gt;
<i> </i> &lt;dt&gt;&lt;label for="b"&gt;Every subsequent day after 48 hours&lt;/label&gt;&lt;/dt&gt;
<i> </i> &lt;dd&gt;&lt;input type="text" id="b"&gt;&lt;/dd&gt;
<i> </i> &lt;dt&gt;&lt;label for="c"&gt;TLX/Fax/Ship call&lt;/label&gt;&lt;/dd&gt;
<i> </i> &lt;dd&gt;&lt;input type="text" id="c"&gt;&lt;/label&gt;&lt;/dd&gt;
<i> </i> &lt;dt&gt;&lt;label for="d"&gt;Agent transport fee&lt;/label&gt;&lt;/dt&gt;
<i> </i> &lt;dd&gt;&lt;input type="text" id="d"&gt;&lt;/label&gt;&lt;/dd&gt;
<i> </i> &lt;dt&gt;&lt;label for="e"&gt;Crew change (excluding transport/hotel/boat chanrge &amp;amp;#8212; if any)&lt;/label&gt;&lt;/dd&gt;
<i> </i> &lt;dd&gt;&lt;input type="text" id="e"&gt;&lt;/dd&gt;
<i> </i> &lt;dt&gt;&lt;label for="f"&gt;Agency service boat&lt;/label&gt;&lt;/dt&gt;
<i> </i> &lt;dd&gt;&lt;input type="text" id="f"&gt;&lt;/dd&gt;
<i> </i> &lt;dt&gt;&lt;label for="g"&gt;Cash to master expenses&lt;/label&gt;&lt;/dt&gt;
<i> </i> &lt;dd&gt;&lt;input type="text" id="g"&gt;&lt;/dd&gt;
<i> </i> &lt;/dl&gt;
<i> </i> &lt;hr&gt;
<i> </i> &lt;label for="total"&gt;Total:&lt;/label&gt;
<i> </i> &lt;input type="text" id="total" value="0"&gt;
<i> </i> &lt;input type="submit" value="Submit"&gt;
<i> </i> &lt;input type="reset"&gt;
<i> </i> &lt;/fieldset&gt;
<i> </i> &lt;/form&gt;
<i> </i>&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @oceanmaid spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...