www.webdeveloper.com
Results 1 to 13 of 13

Thread: Need some help !

  1. #1
    Join Date
    Mar 2013
    Posts
    14

    Need some help !

    Hey, as the title says i need some help. I currently have a contact form ( self made). Easiest way to explain.
    I have a form : http://martinlougas.eu/pood.html . Problem is that on the right side the checkboxes, once you check them the price (shown after the name) has to display in a box under "Summa". Currently it is only showing when all of the boxes are checked. ( Yes i know that one is selected by default, it has to be and it has to be not "deselectable" . After the price displaying is okay, it should send it to certain email with all the info ( boxes) selected and showing the price.

    If it was hard to understand. If you select for example Line-X then 350 will be added to the "Summa" box, if you deselect it, it will be taken away from there. Default value should be 50 since one of the boxes is always selected.


    Current code is:


    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript">
    // From: http://www.webdeveloper.com/forum/sh...d.php?t=235581

    function getRBtnName(GrpName) {
    var sel = document.getElementsByName(GrpName);
    var fnd = -1;
    var str = '';
    for (var i=0; i<sel.length; i++) {
    if (sel[i].checked == true) { str = sel[i].value; fnd = i; }
    }
    // return fnd; // return option index of selection
    // comment out next line if option index used in line above
    return str;
    }

    function DisplayPrice(price){
    var val1 = getRBtnName('part1').split(',');
    var val2 = getRBtnName('part2').split(',');
    var val3 = getRBtnName('part3').split(',');
    var val4 = getRBtnName('part4').split(',');
    var val5 = getRBtnName('part5').split(',');
    var val6 = getRBtnName('part6').split(',');
    var val7 = getRBtnName('part7').split(',');
    var val8 = getRBtnName('part8').split(',');
    var val9 = getRBtnName('part9').split(',');


    var sum=parseInt(val1[0]) + parseInt(val2[0])+ parseInt(val3[0])+ parseInt(val4[0])+ parseInt(val5[0])+ parseInt(val6[0])+ parseInt(val7[0])+ parseInt(val8[0])+ parseInt(val9[0]);
    document.getElementById('totalSum').value=sum+".00 €";

    }
    onload=function() {
    DisplayPrice();
    }

    </script>
    </head>
    <body>
    <table class="puuks" border="0" cellspacing="0" cellpadding="0">
    <tbody>
    <tr class="puuks">
    <td class="puuks" valign="top" width="350">
    <strong>Valitse oikea kamina:</strong><br>
    <input name="part1" type="radio"
    onclick="DisplayPrice();" value="0" checked="CHECKED">Uppokamina (27kw) - 0 &euro;- vakio<br>
    <input name="part1" type="radio"
    onclick="DisplayPrice();" value="249">Ulkokamina (27kw) - 249.00 &euro;<br>
    <input type="radio" value="279" name="part1"
    onclick="DisplayPrice();">Uppokamina (40kw) - 279.00 &euro;<br>
    <input type="radio" value="395" name="part1"
    onclick="DisplayPrice();">Ulkokamina (40kw) - 395.00 &euro;<br>
    </td>
    <td class="puuks" valign="top" width="350">
    <strong>Kylpytynnyrin lisävarusteet:</strong><br>
    <input type="checkbox" value="0" name="part2"
    onclick="DisplayPrice();">Line – X (suosittelemme) - 350.00 &euro;<br>
    <input type="checkbox" value="49" name="part3"
    onclick="DisplayPrice();">Kansi mänty (suosittelemme) – 49.00 &euro;<br>
    <input type="checkbox" value="45" name="part4"
    onclick="DisplayPrice();">Suojapressu - 45.00 &euro;<br>
    <input type="checkbox" value="40" name="part5"
    onclick="DisplayPrice();">Poltettu mänty – 40.00 &euro;<br>
    <input type="checkbox" value="250" name="part6"
    onclick="DisplayPrice();">Lämpökäsitelty mänty - 250.00 &euro;<br>
    <input type="checkbox" value="50" name="part7" onclick="return false" checked
    onclick="DisplayPrice();">Valmiiksi koottuna – 50.00 &euro;<br>
    <input type="checkbox" value="300" name="part8"
    onclick="DisplayPrice();">Porejärjestelma – 300.00 &euro;<br>
    <input type="checkbox" value="300" name="part9"
    onclick="DisplayPrice();">LED valot - 300.00 &euro;<br>
    </td>
    <td class="puuks" float="right" valign="top">

    <h2>Summa</h2><input type="text" id="totalSum" value="" size="25" readonly border="0">

    <p>Etu- ja sukunimi</p>
    <input name="name" type="text" value="" size="25">
    <p>Sähköposti</p> <input name="email" type="text" size="25">
    <p>Puhelin</p> <input name="email" type="text" size="25">
    <p>Osoite</p> <input name="email" type="text" size="25">
    <p>Lisätietoja</p><textarea name="message" rows="3" cols="21"></textarea><br />
    <input type="submit" value="Tilaa kylpytynnyri">

    </form>
    </td>
    </tr>
    </tbody>
    </table>



    </body>
    </html>


    If something is still not understandable please tell me. Sorry for my bad english.

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,257

    Lightbulb

    You have a number of syntax errors in the script...
    1. You cannot read the checkbox status with the radio button function "getRBtn()"
    2. CSS comments are not // they are /* [comment] */ only

    Look at changes made here...
    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>
    <table class="puuks" border="0" cellspacing="0" cellpadding="0">
     <tbody>
      <tr class="puuks">
       <td class="puuks" valign="top" width="350"> <strong>Valitse oikea kamina:</strong><br>
        <input name="part1" type="radio" onclick="DisplayPrice();" value="0" checked="CHECKED">
         Uppokamina (27kw) - 0 &euro;- vakio<br>
       <input type="radio" value="249" name="part1" onclick="DisplayPrice();">Ulkokamina (27kw) - 249.00 &euro;<br>
       <input type="radio" value="279" name="part1" onclick="DisplayPrice();">Uppokamina (40kw) - 279.00 &euro;<br>
       <input type="radio" value="395" name="part1" onclick="DisplayPrice();">Ulkokamina (40kw) - 395.00 &euro;<br>
      </td>
    
      <td class="puuks" valign="top" width="350"> <strong>Kylpytynnyrin lisävarusteet:</strong><br>
       <input type="checkbox" value="350" id="part2" onclick="DisplayPrice();">Line – X (suosittelemme) - 350.00 &euro;<br>
       <input type="checkbox" value="49" id="part3" onclick="DisplayPrice();">Kansi mänty (suosittelemme) – 49.00 &euro;<br>
       <input type="checkbox" value="45" id="part4" onclick="DisplayPrice();">Suojapressu - 45.00 &euro;<br>
       <input type="checkbox" value="40" id="part5" onclick="DisplayPrice();">Poltettu mänty – 40.00 &euro;<br>
       <input type="checkbox" value="250" id="part6" onclick="DisplayPrice();">Lämpökäsitelty mänty - 250.00 &euro;<br>
       <input type="checkbox" value="50" id="part7" checked onclick="return false" readonly>Valmiiksi koottuna – 50.00 &euro;<br>
       <input type="checkbox" value="300" id="part8" onclick="DisplayPrice();">Porejärjestelma – 300.00 &euro;<br>
       <input type="checkbox" value="300" id="part9" onclick="DisplayPrice();">LED valot - 300.00 &euro;<br>
      </td>
    
      <td class="puuks" float="right" valign="top">
       <h2>Summa</h2><input type="text" id="totalSum" value="" size="25" readonly border="0">
    
    <p>Etu- ja sukunimi</p>
    <input name="name" type="text" value="" size="25">
    <p>Sähköposti</p> <input name="email" type="text" size="25">
    <p>Puhelin</p> <input name="email" type="text" size="25">
    <p>Osoite</p> <input name="email" type="text" size="25">
    <p>Lisätietoja</p><textarea name="message" rows="3" cols="21"></textarea><br />
    <input type="submit" value="Tilaa kylpytynnyri">
    
    </form>
    </td>
    </tr>
    </tbody>
    </table>
    
    <script type="text/javascript">
    // From: http://www.webdeveloper.com/forum/sh...d.php?t=235581
    
    function getRBtnName(GrpName) {
      var sel = document.getElementsByName(GrpName);
      var fnd = -1;
      var str = '';
      for (var i=0; i<sel.length; i++) {
        if (sel[i].checked == true) { str = sel[i].value; fnd = i; }
      }
    // return fnd; // return option index of selection
    // comment out next line if option index used in line above
      return str;
    }
    
    function DisplayPrice(){
      var sum = 0;
      sum += Number(getRBtnName('part1')); // .split(',');   ??? NOTHING TO SPLIT IN VALUE OF PART1 ???
      for (var i=2; i<10; i++) {
        var el = document.getElementById('part'+i);
        if (el.checked) { sum += Number(el.value); } // ??? PART2..PART9 are CHECKBOX not RADIO ???
      } 
      document.getElementById('totalSum').value=sum.toFixed(2)+" €";
    }
    DisplayPrice();
    
    </script>
    </body>
    </html>

  3. #3
    Join Date
    Mar 2013
    Posts
    14
    I don't have enough words how to thank you, mate. Now all i gotta do is figure out how to send all that info to a certain email address. Showing what radio button was clicked and what checkboxes have been clicked + all the data from contant form as well.

    Again, thank you so much JMRKER

  4. #4
    Join Date
    Mar 2013
    Posts
    14
    I know it might be wrong post where to type it, but could anyone help me creating a mail.php. What should i write there in order to send the checked checkbox info and selected radio button info to email ?

  5. #5
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,257
    Quote Originally Posted by martinlougas View Post
    I don't have enough words how to thank you, mate. Now all i gotta do is figure out how to send all that info to a certain email address. Showing what radio button was clicked and what checkboxes have been clicked + all the data from contant form as well.

    Again, thank you so much JMRKER
    You're most welcome.
    Happy to help.

    You should be able to have access to a program similar to "formmail.cgi" on your server.
    Most have it or something like it. Check with your administrator.

    Good Luck!

  6. #6
    Join Date
    Mar 2013
    Posts
    14
    Hey, is it possible to add some text to the value part without messing up the calculator ?

    <input type="checkbox" value="45" id="part4" onclick="DisplayPrice();">Suojapressu - 45.00 &euro;<br> To add something like suojapressu (because this form has to send the selected value as an email to certain email)

  7. #7
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,257
    I'm sorry but I don't understand the question.
    It is probably because I can't read the language, but that is my problem.

    If you add something to the "DisplayPrice()" function, you will be adding it to ALL actions of the checkbox change.
    Is that your real need or is it that you wish to submit the total to the email after ALL checkboxes have been selected?

    If the latter is the real need, you would be better off creating a new function that could be executed
    to send the information via a <form> tag assignment using the "onsubmit="return someFunctionToEmail()"
    See <input> tag with type="submit" value="Submit" via a google search. This would create a 'submit' button.

  8. #8
    Join Date
    Mar 2013
    Posts
    14
    Okay let me try to make it more understandable.
    Currently if i send the email it posts the value="value" to the email. BUT is it possible to send
    <input type="checkbox" value="350" id="part2" onclick="DisplayPrice();">Line – X (suosittelemme) - 350.00 &euro
    ( see the bold part ) as well ?
    I tried to add the name to value as value="350, linex" but that only messed up the calculator and it displays NaN. But in the email it says correctly what it needs to display.

    Im having hard time explaining it, really sorry about that.

    If you have msn or smth you could add me there mindfr34k@hotmail.com i could explain better maybe

  9. #9
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,257

    Lightbulb

    Quote Originally Posted by martinlougas View Post
    Okay let me try to make it more understandable.
    Currently if i send the email it posts the value="value" to the email. BUT is it possible to send
    <input type="checkbox" value="350" id="part2" onclick="DisplayPrice();">Line – X (suosittelemme) - 350.00 &euro
    ( see the bold part ) as well ?
    I tried to add the name to value as value="350, linex" but that only messed up the calculator and it displays NaN. But in the email it says correctly what it needs to display.

    Im having hard time explaining it, really sorry about that.

    If you have msn or smth you could add me there mindfr34k@hotmail.com i could explain better maybe
    You have not indicated how you plan on saving the extra information nor how you plan to send it to your server,
    so I'll leave that up to you using the information created in the "DisplayPrice()" function.

    Note the other changes I made to the radiobutton and checkbox value settings.

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>
    <table class="puuks" border="0" cellspacing="0" cellpadding="0">
     <tbody>
      <tr class="puuks">
       <td class="puuks" valign="top" width="350"> <strong>Valitse oikea kamina:</strong><br>
        <input name="part1" type="radio" onclick="DisplayPrice();" value="0,uppokamina27" checked="CHECKED">
         Uppokamina (27kw) - 0 &euro;- vakio<br>
       <input type="radio" value="249,ulkokamina" name="part1" onclick="DisplayPrice();">Ulkokamina (27kw) - 249.00 &euro;<br>
       <input type="radio" value="279,uppokamina40" name="part1" onclick="DisplayPrice();">Uppokamina (40kw) - 279.00 &euro;<br>
       <input type="radio" value="395,ulkokamina" name="part1" onclick="DisplayPrice();">Ulkokamina (40kw) - 395.00 &euro;<br>
      </td>
    
      <td class="puuks" valign="top" width="350"> <strong>Kylpytynnyrin lisävarusteet:</strong><br>
       <input type="checkbox" value="350,linex" id="part2" onclick="DisplayPrice();">Line – X (suosittelemme) - 350.00 &euro;<br>
       <input type="checkbox" value="49,kansi" id="part3" onclick="DisplayPrice();">Kansi mänty (suosittelemme) – 49.00 &euro;<br>
       <input type="checkbox" value="45,suojapressu" id="part4" onclick="DisplayPrice();">Suojapressu - 45.00 &euro;<br>
       <input type="checkbox" value="40,poltettu" id="part5" onclick="DisplayPrice();">Poltettu mänty – 40.00 &euro;<br>
       <input type="checkbox" value="250,manty" id="part6" onclick="DisplayPrice();">Lämpökäsitelty mänty - 250.00 &euro;<br>
       <input type="checkbox" value="50,valmiiksi" id="part7" checked onclick="return false" readonly>Valmiiksi koottuna – 50.00 &euro;<br>
       <input type="checkbox" value="300,porejarjestelma" id="part8" onclick="DisplayPrice();">Porejärjestelma – 300.00 &euro;<br>
       <input type="checkbox" value="300,led" id="part9" onclick="DisplayPrice();">LED valot - 300.00 &euro;<br>
      </td>
    
      <td class="puuks" float="right" valign="top">
       <h2>Summa</h2><input type="text" id="totalSum" value="" size="25" readonly border="0">
    
    <p>Etu- ja sukunimi</p>
    <input name="name" type="text" value="" size="25">
    <p>Sähköposti</p> <input name="email" type="text" size="25">
    <p>Puhelin</p> <input name="email" type="text" size="25">
    <p>Osoite</p> <input name="email" type="text" size="25">
    <p>Lisätietoja</p><textarea name="message" rows="3" cols="21"></textarea><br />
    <input type="submit" value="Tilaa kylpytynnyri">
    
    </form>
    </td>
    </tr>
    </tbody>
    </table>
    
    <script type="text/javascript">
    // From: http://www.webdeveloper.com/forum/sh...d.php?t=235581
    
    function getRBtnName(GrpName) {
      var sel = document.getElementsByName(GrpName);
      var fnd = -1;
      var str = '';
      for (var i=0; i<sel.length; i++) {
        if (sel[i].checked == true) { str = sel[i].value; fnd = i; }
      }
    // return fnd; // return option index of selection
    // comment out next line if option index used in line above
      return str;
    }
    
    function DisplayPrice(){
      var sum = 0;  
      var tarr = getRBtnName('part1').split(',');
      sum += Number(tarr[0]); // .split(',');
      var emailInfo = tarr[1];
      for (var i=2; i<10; i++) {
        var el = document.getElementById('part'+i);
        if (el.checked) {
          tarr = el.value.split(',');
          sum += Number(tarr[0]);
          emailInfo += ','+tarr[1];    // saved for email purposes
        }
      } 
      document.getElementById('totalSum').value=sum.toFixed(2)+" €";
      alert(emailInfo);
    }
    DisplayPrice();
    
    </script>
    </body>
    </html>

  10. #10
    Join Date
    Mar 2013
    Posts
    14
    Thanks, it works abit, but not fully. When sending the form it says error on line 10 (on contact.php)

    foreach($_POST['cbox'] as $value) {
    $check_boxes .= $value." ";
    }


    Those lines. But it still sends the email. In the email the radio button values are correct but the checkbox field has lost its numeric value now, it just leaves empty line now.

  11. #11
    Join Date
    Mar 2013
    Posts
    14
    Sorry was my bad, i forgot to add name="cbox[]" to the checkbox inputs, all good now. Many many many many thanks to you mate !

  12. #12
    Join Date
    Mar 2013
    Posts
    14
    Hey, some quick questions again. Need to add few values. There has to be a dropdown list with certain values and add the value of them to totalSum
    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    .vahe { margin-top: -1px;
    margin-bottom: -2px;
    }
    .vahe2 { margin-top: -17px;
    margin-bottom: 15px;
    }
    </style>
    </head>	
    <body>
    <table class="puuks" border="0" cellspacing="0" cellpadding="0">
     <tbody>
      <tr class="puuks">
       <td class="puuks" valign="top" width="350">
       <form action="contact.php" method="post" >
       
       <form name="calc" id="calc" onSubmit="return false;">
       <strong>Valitse Kylpytynnyri</strong>
       <br>
      <select name="num" id="num" onChange="calcForm(this.form);"> 
        <option value="1">Kylpytynnyri Ø 160 cm - 849.00 &euro;</option>
        <option value="2">Kylpytynnyri Ø 180 cm - 909.00 &euro;</option>
        <option value="3">Kylpytynnyri Ø 200 cm - 959.00 &euro;</option>
        <option value="4">Kylpytynnyri Ø 220 cm - 1’029.00 &euro;</option>
        <option value="5">Kylpytynnyri Ø 240 cm - 1’129.00 &euro;</option>
      </select>
      </form>
       <br>
       <br>
        <strong>Valitse oikea kamina:</strong><br>
        <input name="part1" type="radio" onClick="DisplayPrice();" value="0,uppokamina27" checked="CHECKED">
         Uppokamina (27kw) - 0 &euro;- vakio<br>
       <input type="radio" value="249,ulkokamina27" name="part1" onClick="DisplayPrice();">Ulkokamina (27kw) - 249.00 &euro;<br>
       <input type="radio" value="279,uppokamina40" name="part1" onClick="DisplayPrice();">Uppokamina (40kw) - 279.00 &euro;<br>
       <input type="radio" value="395,ulkokamina40" name="part1" onClick="DisplayPrice();">Ulkokamina (40kw) - 395.00 &euro;<br>
      </td>
    
      <td class="puuks" valign="top" width="350"> 
      <strong>Kylpytynnyrin lisävarusteet:</strong><br>
       <input type="checkbox" name="cbox[]" value="350,linex," id="part2" onClick="DisplayPrice();">Line – X (suosittelemme) - 350.00 &euro;<br>
       <input type="checkbox" name="cbox[]"  value="49,kansi," id="part3" onClick="DisplayPrice();">Kansi mänty (suosittelemme) – 49.00 &euro;<br>
       <input type="checkbox"  name="cbox[]" value="45,suojapressu," id="part4" onClick="DisplayPrice();">Suojapressu - 45.00 &euro;<br>
       <input type="checkbox" name="cbox[]"  value="40,poltettu," id="part5" onClick="DisplayPrice();">Poltettu mänty – 40.00 &euro;<br>
       <input type="checkbox" name="cbox[]"  value="250,lampokasitelty," id="part6" onClick="DisplayPrice();">Lämpökäsitelty mänty - 250.00 &euro;<br>
       <input type="checkbox" name="cbox[]"  value="50,valmiiksi," id="part7" checked onClick="return false" readonly>Valmiiksi koottuna – 50.00 &euro;<br>
       <input type="checkbox" name="cbox[]"  value="300,porejarjestelma," id="part8" onClick="DisplayPrice();">Porejärjestelma – 300.00 &euro;<br>
       <input type="checkbox"  name="cbox[]" value="300,led," id="part9" onClick="DisplayPrice();">LED valot - 300.00 &euro;<br>
      </td>
    
       <td class="puuks" float="right" valign="top">
       <h2>Summa</h2>
       <input class="vahe2" name="summa" type="text" id="totalSum" value="" size="25" readonly border="0">
    
    <p class="vahe">Etu- ja sukunimi</p>
    <input name="name" type="text" value="" size="25">
    <p  class="vahe">Sähköposti</p> <input name="email" type="text" size="25">
    <p  class="vahe">Puhelin</p> <input name="puhelin" type="text" size="25">
    <p  class="vahe">Osoite</p> <input name="osoite" type="text" size="25">
    <p  class="vahe">Lisätietoja</p><textarea name="message" rows="3" cols="21"></textarea><br />
    <input type="submit" value="Tilaa kylpytynnyri">
    
    </form>
    </td>
    </tr>
    </tbody>
    </table>
    
    <script type="text/javascript">
    // From: http://www.webdeveloper.com/forum/sh...d.php?t=235581
    
    function getRBtnName(GrpName) {
      var sel = document.getElementsByName(GrpName);
      var fnd = -1;
      var str = '';
      for (var i=0; i<sel.length; i++) {
        if (sel[i].checked == true) { str = sel[i].value; fnd = i; }
      }
    // return fnd; // return option index of selection
    // comment out next line if option index used in line above
      return str;
    }
    function calcForm(form,submit_it) { 
    // By making the first element 0, this associates the list precisely with the select list. 
    // To maintain all you need to do is change this array. 
    var prices = new Array('0.00', '849.00','909.00','959.00','1029.00','1129.00');  
    var sel = document.getElementById('num'); // The list 
    var ind = sel.selectedIndex; // What's selected 
    var total = document.getElementById('totalSum'); 
    total.value = prices[sel[ind].value]; // the correlating value from the array 
    } 
    function DisplayPrice(){	
      var sum = 0;  
      var tarr = getRBtnName('part1').split(',');
      sum += Number(tarr[0]); // .split(',');
      var emailInfo = tarr[1];
      for (var i=2; i<10; i++) {
        var el = document.getElementById('part'+i);
        if (el.checked) {
          tarr = el.value.split(',');
          sum += Number(tarr[0]);
          emailInfo += ','+tarr[1];    // saved for email purposes
        }
      } 
      document.getElementById('totalSum').value=sum.toFixed(2)+" €";
    }
    DisplayPrice();
    
    </script>
    </body>
    </html>
    The dropdown list prices are displayed in the totalSum box, but it doesn't include other selected prices there

    Example of the page http://martinlougas.eu/hinnat.html

  13. #13
    Join Date
    Mar 2013
    Posts
    14
    Hey, some quick questions again. Need to add few values. There has to be a dropdown list with certain values and add the value of them to totalSum
    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    .vahe { margin-top: -1px;
    margin-bottom: -2px;
    }
    .vahe2 { margin-top: -17px;
    margin-bottom: 15px;
    }
    </style>
    </head>	
    <body>
    <table class="puuks" border="0" cellspacing="0" cellpadding="0">
     <tbody>
      <tr class="puuks">
       <td class="puuks" valign="top" width="350">
       <form action="contact.php" method="post" >
       
       <form name="calc" id="calc" onSubmit="return false;">
       <strong>Valitse Kylpytynnyri</strong>
       <br>
      <select name="num" id="num" onChange="calcForm(this.form);"> 
        <option value="1">Kylpytynnyri Ø 160 cm - 849.00 &euro;</option>
        <option value="2">Kylpytynnyri Ø 180 cm - 909.00 &euro;</option>
        <option value="3">Kylpytynnyri Ø 200 cm - 959.00 &euro;</option>
        <option value="4">Kylpytynnyri Ø 220 cm - 1’029.00 &euro;</option>
        <option value="5">Kylpytynnyri Ø 240 cm - 1’129.00 &euro;</option>
      </select>
      </form>
       <br>
       <br>
        <strong>Valitse oikea kamina:</strong><br>
        <input name="part1" type="radio" onClick="DisplayPrice();" value="0,uppokamina27" checked="CHECKED">
         Uppokamina (27kw) - 0 &euro;- vakio<br>
       <input type="radio" value="249,ulkokamina27" name="part1" onClick="DisplayPrice();">Ulkokamina (27kw) - 249.00 &euro;<br>
       <input type="radio" value="279,uppokamina40" name="part1" onClick="DisplayPrice();">Uppokamina (40kw) - 279.00 &euro;<br>
       <input type="radio" value="395,ulkokamina40" name="part1" onClick="DisplayPrice();">Ulkokamina (40kw) - 395.00 &euro;<br>
      </td>
    
      <td class="puuks" valign="top" width="350"> 
      <strong>Kylpytynnyrin lisävarusteet:</strong><br>
       <input type="checkbox" name="cbox[]" value="350,linex," id="part2" onClick="DisplayPrice();">Line – X (suosittelemme) - 350.00 &euro;<br>
       <input type="checkbox" name="cbox[]"  value="49,kansi," id="part3" onClick="DisplayPrice();">Kansi mänty (suosittelemme) – 49.00 &euro;<br>
       <input type="checkbox"  name="cbox[]" value="45,suojapressu," id="part4" onClick="DisplayPrice();">Suojapressu - 45.00 &euro;<br>
       <input type="checkbox" name="cbox[]"  value="40,poltettu," id="part5" onClick="DisplayPrice();">Poltettu mänty – 40.00 &euro;<br>
       <input type="checkbox" name="cbox[]"  value="250,lampokasitelty," id="part6" onClick="DisplayPrice();">Lämpökäsitelty mänty - 250.00 &euro;<br>
       <input type="checkbox" name="cbox[]"  value="50,valmiiksi," id="part7" checked onClick="return false" readonly>Valmiiksi koottuna – 50.00 &euro;<br>
       <input type="checkbox" name="cbox[]"  value="300,porejarjestelma," id="part8" onClick="DisplayPrice();">Porejärjestelma – 300.00 &euro;<br>
       <input type="checkbox"  name="cbox[]" value="300,led," id="part9" onClick="DisplayPrice();">LED valot - 300.00 &euro;<br>
      </td>
    
       <td class="puuks" float="right" valign="top">
       <h2>Summa</h2>
       <input class="vahe2" name="summa" type="text" id="totalSum" value="" size="25" readonly border="0">
    
    <p class="vahe">Etu- ja sukunimi</p>
    <input name="name" type="text" value="" size="25">
    <p  class="vahe">Sähköposti</p> <input name="email" type="text" size="25">
    <p  class="vahe">Puhelin</p> <input name="puhelin" type="text" size="25">
    <p  class="vahe">Osoite</p> <input name="osoite" type="text" size="25">
    <p  class="vahe">Lisätietoja</p><textarea name="message" rows="3" cols="21"></textarea><br />
    <input type="submit" value="Tilaa kylpytynnyri">
    
    </form>
    </td>
    </tr>
    </tbody>
    </table>
    
    <script type="text/javascript">
    // From: http://www.webdeveloper.com/forum/sh...d.php?t=235581
    
    function getRBtnName(GrpName) {
      var sel = document.getElementsByName(GrpName);
      var fnd = -1;
      var str = '';
      for (var i=0; i<sel.length; i++) {
        if (sel[i].checked == true) { str = sel[i].value; fnd = i; }
      }
    // return fnd; // return option index of selection
    // comment out next line if option index used in line above
      return str;
    }
    function calcForm(form,submit_it) { 
    // By making the first element 0, this associates the list precisely with the select list. 
    // To maintain all you need to do is change this array. 
    var prices = new Array('0.00', '849.00','909.00','959.00','1029.00','1129.00');  
    var sel = document.getElementById('num'); // The list 
    var ind = sel.selectedIndex; // What's selected 
    var total = document.getElementById('totalSum'); 
    total.value = prices[sel[ind].value]; // the correlating value from the array 
    } 
    function DisplayPrice(){	
      var sum = 0;  
      var tarr = getRBtnName('part1').split(',');
      sum += Number(tarr[0]); // .split(',');
      var emailInfo = tarr[1];
      for (var i=2; i<10; i++) {
        var el = document.getElementById('part'+i);
        if (el.checked) {
          tarr = el.value.split(',');
          sum += Number(tarr[0]);
          emailInfo += ','+tarr[1];    // saved for email purposes
        }
      } 
      document.getElementById('totalSum').value=sum.toFixed(2)+" €";
    }
    DisplayPrice();
    
    </script>
    </body>
    </html>
    The dropdown list prices are displayed in the totalSum box, but it doesn't include other selected prices there

    Example of the page http://martinlougas.eu/hinnat.html

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles