/    Sign up×
Community /Pin to ProfileBookmark

Javascript and forms question

I’m being pressured to set up a website for the shop I work at since I know a little about coding and web design. However, my boss wants me to design a page where people can put in measurements for banners (we make banners and signs, and he wants to sell blank banners online) and get a quote on them back. I actually know very little about javascript, but I’ve seen just about every piece of information in regards to the coding that can do this. I just don’t know how to put everything together to make it all work. Basically what I need is a piece of code that multiplies three numbers, two being changeable and one being fixed, and displays the output when the form is filled out and the submit button is pressed. I would definitely appreciate some help on this matter. My job may be at stake.

Here is the javascript that I have. How do I get the numbers involved to take on the value that would be entered into a textbox?

[code=php]<head>

<script type=”text/javascript”>
function total(numberA,numberB)
{
return numberA * numberB * .50
}
</script>

</head>
<body>

<script type=”text/javascript”>
document.write(total(1,2))
</script>

</body>[/code]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@ai3rulesJan 08.2005 — Hi, I don't know if I got the math right, but is this something like what you want?

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>New Page 1</title>

<script language="javascript">

<!--

function total(){

var one = document.form1.numberOne.value;

var two = document.form1.numberTwo.value;

var fixed = .50

var calc1 = Number(one * two).toFixed(2)

var calc2 = Number(calc1 *
fixed).toFixed(2)

document.getElementById('output').innerText = Number(calc2)

}

//-->

</script>

</head>

<body>

<form name="form1">

<input type="text" name="numberOne"><br>

<input type="text" name="numberTwo"><br>

<input type="button" value="Submit" onclick="total()">

</form>

<div id="output"></div>

</body>

</html>
Copy linkTweet thisAlerts:
@thunderbeardauthorJan 08.2005 — That's actually perfect for what I need. I do appreciate it greatly. I also have seen how to integrate the form into the javascript. That will definitely come in handy later. Thanks again. I'll post a link to the site on here when I get it done, which should be in the next week or so.
Copy linkTweet thisAlerts:
@ai3rulesJan 08.2005 — Great! I am glad to help.
×

Success!

Help @thunderbeard 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.18,
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,
)...