Re: Form Process Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gary wrote:
> My my, someone woke up on the wrong side of the bracket....
> 
> Acutally, the silliness of the request has not been lost on me or the 
> client.  And no, it is a simple 195 times number of people, which is usually 
> under 5, so, I understand your recent scratching of the head...
> 
> I was thinking/hoping there was some mechanism that would calculate the 
> amount without hitting the submit button, something like a OnExit command. 
> Something that I would not have to work around the validation feilds being 
> lost and without having to make up a couple of new files...
> 

There is, it's called javascript ;-) and for this application it should
be very easy.  Something like this (not tested), or a variation:

<script type="text/javascript">
function calculateTotal()
{
	var qty = document.getElementById('qty').value;
	var cost = document.getElementById('cost').value;
	document.getElementById('total').value = (qty * cost);
}
</script>
</head>
<body>

<form ..........>
<input type="hidden" id="cost" value="195" />
Quantity:
<input type="text" name="qty" id="qty" value="0"
onchange="calculateTotal()" />
Total:
<input type="text" name="total" id="total" value="0" />
.................
</form>

> Gary
> 
> 
> "Daniel Brown" <danbrown@xxxxxxx> wrote in message 
> news:ab5568160906160858u2e670fc4gcd0749334126ed71@xxxxxxxxxxxxxxxxx
> On Tue, Jun 16, 2009 at 11:03, Gary<gwpaul@xxxxxxx> wrote:
>> I have a client that I have made some forms for. On one of the forms, 
>> their
>> customers are to registar for a class. The cost of the class is 195 per
>> person. She would like to have the people be able to have the total cost
>> calculated for them before they submit the form. (I already have the cost
>> calculated in the email and result page).
> 
>     Just to point something out here: based upon the information you
> sent to the list, this question sounds ridiculous, because on the
> surface, it sounds like, "the class is $195, so how should I calculate
> this as a total?"  ;-P
> 
>     Sometimes, when doing a project, we forget that *we* know all of
> the information, but those with whom we're trying to communicate do
> not.  What other figures would be calculated into this?  Is there tax
> levied in certain circumstances (like if they live in Pennsylvania)?
> Is there an option for registering and paying for multiple
> participants on a single order?  Can they pay for more than one class
> at once?  Are prices meant to be pulled in real-time from a database
> or other remote or dynamic source?
> 
>     If all of the above questions are no, then it's even easier:
> 
> <?php
> $amount = 195;
> 
> setlocale(LC_MONETARY,'en_US');
> echo money_format('%n',$amount);
> ?>
> 
>     If even one of the questions above is answered with a 'yes,' then
> you'll want to consider the alternatives and weigh each option.  Maybe
> you'll want to use JavaScript, maybe you'll want to do server-side
> processing --- maybe a combination of both (i.e. - AJAX) if you need
> to pull from the database and want to present the information without
> refreshing/reloading a page.
> 

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux