Form Values

P

portchey

Hi,

Excuse my lack of knowledge about javascript, I have a question that
I'm stumped on.

I have a form that has many text boxes that the user enters the
quantity of an item. Each item has a unit value.
How do I display on the page the total value of each item next to each
text box as the user enters the quantity in each text box in turn.

I feel the "onblur" event may be the event to use for each text box but
can't seem to get the calculated value displayed on the page.

Thanks for any advice.

Phil.
 
V

VK

portchey said:
I have a form that has many text boxes that the user enters the
quantity of an item. Each item has a unit value.
How do I display on the page the total value of each item next to each
text box as the user enters the quantity in each text box in turn.


<html>
<head>
<title>Calculate</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function recalculate(goody) {
var output = document.getElementById(goody.id+'total');
var quantity = goody.value;
if (!isNaN(parseInt(quantity,10))) {
var price = goody.getAttribute('price');
output.innerHTML = quantity*price;
}
else {
output.innerHTML = 0;
}
}
</script>
</head>

<body bgcolor="#FFFFFF">

<form name="myForm">
<label for="item001">Item 1:</label>
<input type="text" name="item001" id="item001"
size="3" maxlength="3" value="0" price="25"
onfocus="this.select();"
onkeyup="recalculate(this);">
<span>Total: $<span id="item001total">0</span></span>
</form>

</body>
</html>
 
P

portchey

Hi all,

How would I apply the same process but use a drop down menu for the
quantity instead of entering the value in a text box.

Thanks very much for any guidence.

Phil.
 
R

Randy Webb

portchey said the following on 8/4/2005 4:34 PM:

I'm not "all" but hi.
How would I apply the same process but use a drop down menu for the
quantity instead of entering the value in a text box.

"Same process" as what? Quote what you are replying to and that becomes
self-evident.
Thanks very much for any guidence.

Guidance: Read the group FAQ, thoroughly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top