PDA

View Full Version : Help Please!


serenaloce146
01-11-2006, 07:49 AM
Hey,
Im don't know much when it comes to web coding except for the very basics (html), so this is what I need help with:

I need to make a form that will do a calculation, like an email form. I use a remote host for my forms because my server doesn't have cgi and etc. My question is, how do I make calculations in my form? Javascript? xml? I don't know I've looked everywhere!

Basically I want their to 3 fields (F1, F2, and F3), the first two which are drop down menus. I want the # in F1 to TIMES whatever # is selected in F2 and then divide that # by 10 AND THEN have the total appear in the textfield F3 - F3 in currency format.

Is this posible to do without being able to do pearl, cgi, php and all that other stuff????

Anyone who can help me or refer me to a source would be greatly appreciated! Thanks!

_Aerospace_Eng_
01-11-2006, 07:54 AM
Its done in javascript. Basic multiplication and division. Is this an assignment?

serenaloce146
01-11-2006, 08:02 AM
No not an assignment, I'm trying to build a website for a friend of mine and having that feature in the form is important for her. Do you know where I can find a similar code or a great tutor website? I'd ask if you could provide the code, but I'm not sure how much work that is.

Thanks for responding.

_Aerospace_Eng_
01-11-2006, 08:08 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function calculate(){
var F1num = Number(document.forms[0].F1.value);
var F2num = Number(document.forms[0].F2.value);
document.forms[0].F3.value = (F1num * F2num) / 10;
return false;
}
</script>
</head>

<body>
<form action="#" method="post" onsubmit="return calculate()">
<div>
<select name="F1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="F2">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<input type="text" name="F3" readonly="readonly">
<input type="submit" value="Calculate">
</div>
</form>
</body>
</html>

serenaloce146
01-11-2006, 08:12 AM
I love you.......
I just spent the last 4 hours looking for this code. I should have posted my question on this forum first ^_^

Thank you so much for your help :)

serenaloce146
01-11-2006, 08:16 AM
Oh one last question, and I hate to bother, but is there a way to make the total # into dollar amount?

_Aerospace_Eng_
01-11-2006, 08:26 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function calculate(){
var F1num = Number(document.forms[0].F1.value);
var F2num = Number(document.forms[0].F2.value);
document.forms[0].F3.value += (F1num * F2num) / 10;
return false;
}
</script>
</head>

<body>
<form action="#" method="post" onsubmit="return calculate()">
<div>
<select name="F1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="F2">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<input type="text" name="F3" value="$" readonly="readonly">
<input type="submit" value="Calculate">
</div>
</form>
</body>
</html>

serenaloce146
01-11-2006, 10:16 AM
I'm trying to get a javascript code to work, but as always it's never that easy for me. I am trying to get the reset button ONLY to clear either just F3 for F1-F3 w/out deleting any other fields I decide to put in the form. I tried using the code from this website ( http://codepunk.hardwar.org.uk/ajs25.htm ), but it just confused me even more. I don't know how to implement it with the code I already have:

Also, I already know I'm going to have problems when I get to it...what else and where else do I put the code so that no matter how many more fields I ad, when someone presses SUBMIT it will be emailed to me? The beginning of my forms usually look like this:

<form method="post" action="http://submit.mailmyform.com" name="mailmyform_form">
<input type="hidden" name="mailmyform_username" value="Jess">


Code to work with:

<form action="#" method="POST" onsubmit="return calculate()" style="font-size: 10pt; font-family: Verdana; color:#FFFFFF; background-color:#FFFFFF">
<div>
<select name="F1" style="font-family: Verdana; font-size: 10pt; letter-spacing: 0; border: 1px solid #606060">
<option value="0">Width</option>
<option value="20">20</option>
<option value="40">40</option>
<option value="60">60</option>

</select> <font face="verdana" size="2" color="black">x</font>
<select name="F2" style="font-family: Verdana; font-size: 10pt; border: 1px solid #606060">
<option value="0">Height</option>
<option value="20">20</option>
<option value="40">40</option>
<option value="60">60</option>

</select><p>

<input type="submit" value="Calculate" style="font-family: Verdana; font-size: 8pt; border: 1px solid #606060">&nbsp;&nbsp;
<input type="text" name="F3" value="$" readonly="readonly" size="9" style="font-family: Verdana; font-size: 10pt; border: 1px solid #606060">

<a href="javascript:document.forms[0].reset()">
<img src="clear_button.gif" border="0"></a>&nbsp;<br>&nbsp;</p>
</div>
</form>

_Aerospace_Eng_
01-11-2006, 10:33 AM
<a href="javascript:document.forms[0].F1.value='$'"><img src="clear_button.gif" border="0"></a>

serenaloce146
01-11-2006, 03:04 PM
Umm, that code didn't work. It actually deleted everything by the "$" symbol.