i want to made a form

in which there is three fields.

1. product value: suppose:1500

2. number of product:2

3. then i want to show multiple of these values in third textbox without submitting form . how can i do this.


help me

Please use this code and make this thread Solved

<html>
<head>


<SCRIPT language=javascript type="text/javascript">

function calculate() {

document.form1.elements.totalbox.value =
(document.form1.elements.productvalue.value
* document.form1.elements.NoOfProducts.value);
}
</script>
<body >
 
<form name="form1" action="post" >

<input type="text" name="productvalue" size="35" maxlength="100" class="blackCopy" value=""
onblur="calculate();" onKeyUp="calculate();this.blur();this.focus();" onChange="calculate();">

<input type="text" name="NoOfProducts" size="35" maxlength="100" class="blackCopy" value=""
onblur="calculate();" onKeyUp="calculate();this.blur();this.focus();" onChange="calculate();">


<input type="text" name ="totalbox" size="5" maxlength="5">
</form>

Hope this will work.

Just to make it better add this lines to the calculate function above to be sure you are multiplying numbers only!

function calculate() {
if(isNan(document.form1.elements.productvalue.value) || isNan( document.form1.elements.NoOfProducts.value)){
alert('Supply some numbers please');
return;
}
document.form1.elements.totalbox.value =
(document.form1.elements.productvalue.value
* document.form1.elements.NoOfProducts.value);
}

and then in the body of the form add this

<input type="button" value="test" onclick="calculate()"/>

CAUTION: Don't use a submit button since it will post to the scrpt specfied!!

i want the same function but for adding two values urgently

can anybody help me in this????plzplz

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.