Welcome visitor
* Login
* Register
It is currently July 22nd, 2019, 10:35 pm
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » JavaScript



Post new topic Reply to topic  [ 3 posts ] 
Author Message
  JavaScript to show the total
PostPosted: August 12th, 2009, 7:18 am 

Posts: 17
Hi, i have a very simple form that is on a site to sell pictures. The problem i have is with the javascript, and is not a big deal either is just that i dont know javascript at all.

The form has one dropdown menu used to select the qty. of pictures to buy and a text input to display the total price to pay.

What i want to do with javascript is to multiply the selected qty. by the price (£ 10.00) and show the total in the input field in the 10.00 format.

This is what i got so far, no javascript at all yet
<form name="store" action="reserve.php">
<select name="qty">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
&nbsp;&nbsp;&nbsp;
£<input name="total" style="width: 4em;" readonly="readonly">
</form>


Top
 Profile  
 
  Re: JavaScript to show the total
PostPosted: August 12th, 2009, 8:09 am 
User avatar

Posts: 71
<script type="text/javascript">
function fillPrice(x){
document.store.total.value=Number(x)*10+'.00'}
</script>
<body onload="fillPrice(document.store.qty.value);">
<form name="store" action="reserve.php">
<select name="qty" onchange="fillPrice(this.value);">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
&nbsp;&nbsp;&nbsp;
£<input name="total" style="width: 4em;" readonly="readonly">
</form>
right?


Top
 Profile  
 
  Re: JavaScript to show the total
PostPosted: August 12th, 2009, 8:29 am 

Posts: 17
yes, thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

FORUMS » Client Side » JavaScript


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron