Web Design Forum  
 
Go Back   Web Design Forum > Web Software > Scripts

Reply
 
LinkBack Thread Tools Display Modes
Old 04-25-2007, 02:49 PM   #1 (permalink)
Bronze Member
 
Join Date: Feb 2007
Location: minnestota
Posts: 81
Default i am wondering y doesnt show answer right away.

the script is set up for an onchange event but in order for it to work u need to leave the input field meaning its acting like it is an onblur event. y wont it change on the entery of new input? ne thoughts........???

<script language="JavaScript">

function calculate()
{
A1 = document.Qty_form.a1.value
A2 = document.Qty_form.a2.value
A3 = (A1*A2)
document.Qty_form.a3.value = A3
}
</script>

<html>
<body>

<form name="Qty_form">
<input type="text" name="a1">
X
<input type="text" name="a2" onChange=calculate();>
=
<input type="text" name="a3" >
</form>

<style type="text/css">
__________________
some times i sits n i thinks ............ some times i jus sits.

Last edited by jmad; 04-25-2007 at 11:01 PM.
jmad is offline   Reply With Quote
Old 04-25-2007, 09:17 PM   #2 (permalink)
Super Noob
 
zkiller's Avatar
 
Join Date: Aug 2004
Location: position:relative
Posts: 1,560
Send a message via AIM to zkiller Send a message via Yahoo to zkiller
Default

1. add a semi-colon ( at the end of each line within the function
2. might want to try declaring your variables as what they are. var A1, etc.

is A1 a set value?
__________________
Stefan, the Post Master

Track Devil - May the boost be with you!
zkiller is offline   Reply With Quote
Old 04-26-2007, 02:27 PM   #3 (permalink)
Bronze Member
 
Join Date: Feb 2007
Location: minnestota
Posts: 81
Default still no good

is this what u meant i still have the problem with it seeming like it is on blur.
<html>
<body>


<script language="JavaScript">

function calculate()
{
A1 = document.Qty_form.quanity.value;
A2 = document.Qty_form.price.value;
A3 = (A1*A2);
document.Qty_form.total.value = A3;
}
</script>

<html>
<body>

<form name="Qty_form">
<input type="text" name="quanity">
X
<input type="text" name="price" onChange=calculate();>
=
<input type="text" name="total" >
</form>

<style type="text/css">

</body>
</html>
__________________
some times i sits n i thinks ............ some times i jus sits.

Last edited by jmad; 04-26-2007 at 02:29 PM.
jmad is offline   Reply With Quote
Old 04-27-2007, 12:33 AM   #4 (permalink)
Super Noob
 
zkiller's Avatar
 
Join Date: Aug 2004
Location: position:relative
Posts: 1,560
Send a message via AIM to zkiller Send a message via Yahoo to zkiller
Default

something like that...

Code:
<html>
<body>


<script language="JavaScript">

function calculate()
{
var A1 = document.Qty_form.quanity.value;
var A2 = document.Qty_form.price.value;
var A3 = (A1*A2);
document.Qty_form.total.value = A3;
}
</script>

<html>
<body>

<form name="Qty_form" onChange=calculate();>
<input type="text" name="quanity">
X
<input type="text" name="price">
=
<input type="text" name="total" >
</form>

<style type="text/css">

</body>
</html>
seems to be working to me. you will need to finish the action of changing the respective value by either clicking out of the field or hitting enter.
__________________
Stefan, the Post Master

Track Devil - May the boost be with you!
zkiller is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:52 AM.


Computer Forum - Internet Business - Webpage Design

 
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.