Forum Moderators: coopster
I have the following code:
echo ( '<p>Child tickets</p>' );
echo ( '<SELECT NAME="childPrices">' );
echo ( '<option value="1">1</option>' );
echo ( '<option value="2">2</option>' );
echo ( '<option value="3">3</option>' );
echo ( '<option value="4">4</option>' );
echo ( '<option value="5">5</option>' );
echo ( '</SELECT>' );
Say for example the usere selects option 5 from the list.
How do i do it so that as soon as the user selects 5 it multiplies it by 10 and gives the result in a box next to it.
here is rest of code:
<snip>
[edited by: jatar_k at 5:33 pm (utc) on Mar. 4, 2004]
[edit reason] snipped massive code dump [/edit]
Then add this to your select
<SELECT NAME="childPrices" onChange="myFunction()">
Then write your javascript function as follows
function myFunction() {
f = document.forms[0];
f.result.value = f.childPrices.value * 10;
}
And thats it!
$newPrice = (isset($_POST['childPrices']))? $_POST['childPrices'] * 10 : 0;
if (isset($_POST['childPrices'])) {
$newPrice = $_POST['childPrices'] * 10;
} else {
$newPrice = 0;
}