Simple problem, but can't figure it out
Working on a script that will add together dollar values in user selected drop downs and display on the page. I get the script to work if the total is to be displayed in a text box, but I want to do a document.write() to put it as a piece of text. I know the answer is simple, but I just don't have the experience to figure it out. I think it may have something to do with local/global scope of the variable. Searched everywhere for the solution.
Below is the code, thanks to anyone who can help!
-----------------------------------------------------------------
<script language="JavaScript">
function addall()
{
writetotal = document.summing.writetotal.value = parseFloat(document.summing.a.value)
+ parseFloat(document.summing.b.value)
+ parseFloat(document.summing.c.value)
+ parseFloat(document.summing.d.value)
}
</script>
</head>
<body>
<form name="summing">
<td width="502" valign="top">
<select name="a" onChange="addall()">
<option value="0.00">0</option>
<option value="2.95">1</option>
<option value="3.95">2</option>
<option value="4.95">3</option>
<option value="5.95">4</option>
</select><br>
<select name="b" onChange="addall()">
<option value="0.00">0</option>
<option value="2.95">1</option>
<option value="3.95">2</option>
<option value="4.95">3</option>
<option value="5.95">4</option>
</select><br>
<select name="c" onChange="addall()">
<option value="0.00">0</option>
<option value="2.95">1</option>
<option value="3.95">2</option>
<option value="4.95">3</option>
<option value="5.95">4</option>
</select><br>
<select name="d" onChange="addall()">
<option value="0.00">0</option>
<option value="2.95">1</option>
<option value="3.95">2</option>
<option value="4.95">3</option>
<option value="5.95">4</option>
</select><br><br>
<input type="text" name="writetotal" size="5" maxlength="5">
<input type="submit" name="Submit" value=""><br><br>
<script language="JavaScript">
<!-- hide from older browser
document.write("Total: " + writetotal.toFixed(2)) //-->
</script>
</form>
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks