/    Sign up×
Community /Pin to ProfileBookmark

Alright, I been doing a code for caculating Electricty cost. The problem I am having is are they any way of adding a box to type in. I want the users to be able to type in the info and get the correct answers. Not to have to keep going in my script!

Script is right here…

[code=php]<html>
<head>
<title> COOLOLOLOL</title>
<script type=”text/javascript”>

var wattage=2500;

var hourdaily=2;

var days=31;

var cost=0.07;

var item=(“Dishwasher”);

//DONT DO ANYTHING ELSE…………………………………………………………………….

var timeperday=(hourdaily*days);
var watts=1000
var kilowatt=(wattage/watts);
var ans=(kilowatt*timeperday);
var ans2=(ans*cost);

//title

document.write(“CACULATING HOW MUCH ELECTRICTY” + “<br />”);
document.write(“<br />”);
//given
document.write(“GIVEN” + “<br/>”);
document.write(“<br/>”);
//wattage given
document.write(” – Wattage- ” + wattage + ” W” + “<br />”);
document.write(“<br/>”);
//time per day given
document.write(” – Time Per Day- ” + hourdaily + ” hours per day” + “<br />”);
document.write(“<br/>”);
//cost given
document.write(” – Cost- ” + ” $” + cost + ” Per hour” +”<br />”);
document.write(“<br/>”);
//days given
document.write(” – Days- ” + days + “<br/>”);
document.write(“<br/>”);
//formula to caculate kilowatts
document.write(wattage + ” watts / 1000 = ” + kilowatt + ” Kw” );
document.write(“<br/>”);
document.write(“<br/>”);
//formula to caculate Total Hours
document.write(hourdaily + ” Hrs x ” + days + ” days ” + ” = ” + timeperday + ” Total hours”);
document.write(“<br/>”);
document.write(“<br/>”);
document.write(“<br/>”);
//Title to sloving!
document.write(“SLOVING”);
document.write(“<br/>”);
document.write(“<br/>”);
//Formula to caculate Total cost for a (watt) (item)
document.write(“Cost of Electricy= Kilowatt x Total hours x cost IN THAT ORDER”);
document.write(“<br/>”);
document.write(“<br/>”);
//Formula to caculate Total cost for a (watt) (item)
document.write(“= ” + kilowatt + ” Kw ” + ” x ” + timeperday + ” Total Hrs ” + ” x ” +” $ ” + cost);
//Caculating Kw.h x cost
document.write(“<br/>”);
document.write(“<br/>”);
document.write(“= ” + ans + ” Kw.H” + ” x ” + ” $ ” + cost);
document.write(“<br/>”);
document.write(“<br/>”);
document.write(“<br/>”);
//Answering the question
document.write(“ANSWERING”);
document.write(“<br/>”);
document.write(“<br/>”);
document.write(“The total cost for a ” + wattage + ” W ” + item + ” is ” + “$” + Math.round(ans2) + “.00” + “<br />”);
document.write(“<br/>”);
document.write(“<br/>”);

</script>
</head>
<body bgcolor=”yellow”>
</body>
<html>[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@TheAliveWinnerMay 28.2012 — 

Please learn [B]HTML[/B]! You do not have the basics!
------------------------------------------------------


DO NOT use [B]document.write[/B]! Use [B]innerHTML[/B] instead.
------------------------------------------------------


Use <input type="text" /> or <textarea></textarea> for providing

[I]text box[/I] to the user!
------------------------------------------------------


Learn the basics here: W3Schools
------------------------------------------------------


Learn JavaScript here: JavaScript Kit
------------------------------------------------------


Useful info about web developing: thesitewizard.com
×

Success!

Help @Crazykid1099 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...