extracting the value of radio buttons for my page
Posted: Thu Mar 02, 2006 3:59 am
feyd | Please use
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
hi,
i am creating a website which has a page that will allow the viewer to customise a PC. Once the options have been selected i would like to:
a) update the total cost of the pc based on the requirements. I don't know if an update is possible on the fly, i.e. as soon as the customer clicks a radio button the total is updated... although for now i don't mind having to click an update total button and displaying the new total on the same page.
b) email the requirements to myself.
I have so far created the radio buttons... same name different values etc.. and am trying to use a switch statement to test the value of the radio group. I'm not sure where to do the test (for $_POST) and how to keep the selected radio buttons selected after submitting the form to itself... instead of resetting to default.
here's some of my code:Code: Select all
<?php $customprice = $row_Recordset3["itemPrice"]; ?> // just getting the basic price from MySQL db
<form id="form1" name="form1" method="POST" action="$_SERVER['PHP_SELF']"> // form header
// these are some of the radio buttons
<input name="monitor" type="radio" value="radio1" checked="checked" />
15" CRT</label></td>
<input type="radio" name="monitor" value="radio2" />
17"CRT</label></td>
<input type="radio" name="monitor" value="radio3" />
...// and so on..
// here i'm trying to test for the radio buttons after submitting the form to itself.
<?php
switch($_POST['monitor']){
case 'radio1':
$customprice = $customprice - 60000;
break;
case 'radio2':
$customprice = $customprice - 80000;
break;
case 'radio3':
$customprice = $customprice - 70000;
break;
default:
$customprice = $customprice; }?>
// outputting the new price
<?php echo number_format($customprice, 2, ".", ","); ?>feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]