Can someone help me with my problem? I try to make a sum with radio buttons in php, but it doesn't see my value
This are my codes:

    <FORM METHOD="POST" ACTION="12.php" >
    <DIV>Kies uw product:<br>
    <INPUT NAME="product" TYPE="radio" VALUE="400" CHECKED>Opblaas rijdende Eend <br>
    <INPUT NAME="product" TYPE="radio" VALUE="15000">Opblaasbare rijdende televisie <br>
    <INPUT NAME="product" TYPE="radio" VALUE="10000">Opblaas rijdende camera<BR>
    <INPUT NAME="product" TYPE="radio" VALUE="20445">Opblaas auto (elektro/benzine)<br>
    <INPUT NAME="product" TYPE="radio" VALUE="5000">Opblaas rijdende laptop<br><br>
    <INPUT NAME="kleur" TYPE="radio" VALUE="10" CHECKED>Zwart<br>
    <INPUT NAME="kleur" TYPE="radio" VALUE="300">Roze<br>
    <INPUT NAME="kleur" TYPE="radio" VALUE="205">Groen<br>
    <INPUT NAME="kleur" TYPE="radio" VALUE="200">Blauw<br><br>
    Wilt u er appeltaart bij laten leveren?<br>
    <INPUT NAME="appe" TYPE="radio" VALUE="4" CHECKED>Ja<br>
    <INPUT NAME="appe" TYPE="radio" VALUE="0"> Nee<br><br>
    Zo wilt u het geleverd hebben:<br>
    <INPUT NAME="lever" TYPE="radio" VALUE="100" CHECKED>Gewassen<br>
    <INPUT NAME="lever" TYPE="radio" VALUE="250">Gezandstraalt<br>
    <INPUT NAME="lever" TYPE="radio" VALUE="500">Geschuurd<br>
    <INPUT NAME="lever" TYPE="radio" VALUE="200">Gedroogd<br><br>
    <INPUT NAME="submit" TYPE="submit" VALUE="bereken">

and second page:

if (isset($_post["product"])){
$number = $_post["product"] ; 
echo "This is your price $number" ; } 
else {
echo "nothing set" ;
$checkbox1 = isset( $_POST["extra1"] )? 10:  0;
$checkbox2 = isset( $_POST["extra2"] )? 100: 0;
$checkbox3 = isset( $_POST["extra3"] )? 350: 0;
$checkbox4 = isset( $_POST["extra4"] )? 5000: 0;
$checkbox5 = isset( $_POST["extra5"] )? 600: 0;
$checkbox6 = isset( $_POST["extra6"] )? 30:  0;
$checkbox7 = isset( $_POST["extra7"] )? 15: 0;
$checkbox8 = isset( $_POST["extra8"] )? 5: 0;
$sum = $checkbox1 + $checkbox2 + $checkbox3 + $checkbox4 + $checkbox5 + $checkbox6 + $checkbox7 + $checkbox8 ;

But now he echo's always: "nothing set".
Does someone know how to make a sum off the radio buttons?

2 Years
Discussion Span
Last Post by toxicandy

I've already found the answer. I had to make the sum on the seccond page,
without isset. and without the values behind it.

$radio1 = $_POST["product"];

and that was it, then he saw the values.


You can use javascript to add the values.I have use this before.I have radio buttons that have the values and i add these values by clicking on the radio button.I think this will help you little bit.

var Coins = 0;      

                  $(document).ready(function() {

              $('.coin_chk').change(function (e) {
            if ($(this).attr("checked")) {
                Coins = parseInt(Coins,10) + parseInt($(this).val())
                               // alert(Coins);exit;
                // checked
//          return;
                 Coins = parseInt(Coins) - parseInt($(this).val())
                      $("#test input[name=li_0_price]").val(Coins)
            // not checked


            //$("#test input[name=li_0_quantity]").val(Coins)


As stated above you can use JS for real time calculation instead of requiring a second page and the load time. If you still want php I can write a script after I get out of class a little later that will work in php.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.