Jump to content

JavaScript Form Update


stublackett

Recommended Posts

Hi Guys,

 

I've got a purchase system setup on my website... Theres a box titled "quantity" all I want to do is update the total as per the quantity amount.. We charge £45 for the product, So if 1 was entered, Obviously the script would need to do X * 45.

 

Never really touched JavaScript before, so any help / pointers would be appreciated.

 

Example form is @ : http://www.stuartblackett.com/order.php

 

All I want it to do is work out the "Quantity" in the box, Then * 45.. I can do the PHP stuff to calculate the rest, Its just the Java I need.. Possibly AJAX, I dunno hopefully you guys can tell me

Link to comment
Share on other sites

Just an update...

 

I've found a script somewhere, Tried playing about with it.

 

Hopefully along the right lines.......

 

<html>
<head>
<script type="text/javascript">
function UpdateQuantity()  {
   this.form.total.value = this.form.quantity * 45;
}
document.onkeydown=UpdateQuantity;
</script>
</head>
<body>
<form name="form" method="post" >
Quantity:<br />
   <input name="quantity" onfocus="UpdateQuantity();" onkeydown="UpdateQuantity();" type="text" />
   <br />
   Cost: <input name="total" type="text" value="0" size="5" />
</form>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.