Forum Moderators: coopster

Message Too Old, No Replies

(cashless) order totals. textbox & checkbox

textbox checkbox javascript php order total

         

indiguy

10:27 am on Sep 9, 2009 (gmt 0)

10+ Year Member



When the user checks a checkbox for the menu option, the total should grab the textbox entry number, and multiply that with the checkboxes which will carry the price.

textbox is for number of people attending only.

Database driven while loop, it produces checkboxes based on the amount of rows displayed

so, can it be done? (newbee)

SCRIPT type=text/javascript>
<!-- //get the price and total it.
//textbox function
function total() {
var people = choice("+ppl+");
if (people) {
people++
window.location = "sth goes here";
}
}
// checkbox function
function total() {
var buy = choice("+buy+");
if (buy) {
buy++
window.location = "sth goes here";
}
}
-->
</script>

php code:

<form id='people_attending'>
<input type='text' size = 1 maxlength= 3 name='ppl' onkeyup='checkField(this);'>
<form>";
..
..
..

while ( $row = mysql_fetch_array($result) )
{
echo "<tr>";
echo "<input type='hidden' name='id' value='".$row[tea_id]."'>";
echo "<tr><td width= 20% align=center><strong>".$row[tea_choice]."</strong></td></tr>".
"<tr><td width = 70% align=center>".$row[tea_desc]."</td></tr>"."<tr>"."&nbsp;&nbsp\$".
"<td align=center>".$row[tea_price]."</td></tr>";
echo <tr><td align=center><input type='checkbox' value='buy' action='javascript:total(<? echo '.$row['tea_price']'; ?>)"/>'."</td></tr>";
}//while
echo "</tr>";
echo "</form></table></center>";

[edited by: eelixduppy at 2:59 pm (utc) on Sep. 9, 2009]
[edit reason] disabled smileys [/edit]

optik

12:29 pm on Sep 9, 2009 (gmt 0)

10+ Year Member



First of all you have two functions with the same name that's a no no. Also you need to accept the value you are passing to the function i.e function total(price).

You can use on function to grab the current number of people and multiply that by the price selected, it's not really clear what you are trying doing with that total though.

indiguy

10:57 pm on Sep 9, 2009 (gmt 0)

10+ Year Member



my bad!
the total is to show the user the total cost for the amount of people attending an event.
the costs are to do with food dishes.
So, (checkbox) disk1 = $1.00 (checkbox) dish18 = $2.20 * (textbox)50 people = $175