Results 1 to 2 of 2
Thread: count id's using js.
- 05-02-2010, 11:07 AM #1
Member
- Join Date
- May 2010
- Posts
- 1
- Rep Power
- 0
count id's using js.
I have made a simple script that uses checkboxes and textareas.
costumers can type a number in the textarea.
the value of the checkbox is multiplied with the number entered in the textarea.
The outcome is given at 'prijsbepaling' on the bottom,
there is only one problem..
the 'id:total' also at the bottom of the script only counts the value of the checked checkboxes, and not the multiplied outcome..
does anybody know how it would be possible to count
calzone
middel
groot
and display it in 'id: total' ?
Thnx!
Java Code:if(!document.getElementById && document.all) document.getElementById = function(id){ return document.all[id]} var calzone = 0; var middel = 0; var groot = 0; var total = 0; function update(checkbox){ if(checkbox.checked){ total += parseFloat(checkbox.value); } else { total -= parseFloat(checkbox.value); }; document.getElementById("total").innerHTML = "€ " + total.toFixed(2).replace(".", ","); }; <!-- functie voor het verbergen van een element --> function showHide (id) { var style = document.getElementById(id).style if (style.visibility == "hidden") style.visibility = "visible"; else style.visibility = "hidden"; } <!-- vermenigvuldigen --> function multiply(value, multiplier, outputId) { document.getElementById(outputId).innerHTML = "€ " + value * multiplier + ",-"; }XML Code:<tr><td><input type="checkbox" value="3" onclick="showHide('calzone1');update(this);"></input></td><td>€ 3,00</td> <td> <div id="calzone1" style="visibility: hidden;"> <input name="hoeveelheid" type="text" onkeyup="multiply(this.value, 3, 'calzone')" id="hoeveelheid" size="2" maxlength="2"> <label for="hoeveelheid">Maal</label></div> </td></tr> <tr><td><input type="checkbox" value="4.00" onclick="showHide('middel1');update(this);"></input></td><td>€ 4,00</td> <td> <div id="middel1" style="visibility: hidden;"> <input name="hoeveelheid" type="text" onkeyup="multiply(this.value, 4, 'middel')" id="hoeveelheid" size="2" maxlength="2"> <label for="hoeveelheid">Maal</label></div> </td></tr> <tr><td><input type="checkbox" value="5.00" onclick="showHide('groot1');update(this);"></input></td><td>€ 5,00</td> <td> <div id="groot1" style="visibility: hidden;"> <input name="hoeveelheid" type="text" onkeyup="multiply(this.value, 5, 'groot')" id="hoeveelheid" size="2" maxlength="2"> <label for="hoeveelheid">Maal</label></div> </td></tr> <!-- prijsbepaling --> <tr><td></td><td><b>Calzone:</b></td><td id="calzone">€ 0,00</td></tr> <tr><td></td><td><b>Middel:</b></td><td id="middel">€ 0,00</td></tr> <tr><td></td><td><b>Groot:</b></td><td id="groot">€ 0,00</td></tr> <tr><td></td><td><b>Totaal:</b></td><td id="total">€ 0,00</td></tr>
- 05-02-2010, 11:28 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
how to count the given character?
By ashin in forum Advanced JavaReplies: 1Last Post: 10-14-2009, 04:28 PM -
to get count value as a variable
By arunkumarinfo in forum JDBCReplies: 2Last Post: 03-30-2009, 01:32 AM -
Making a count..
By Samgetsmoney in forum New To JavaReplies: 15Last Post: 02-18-2009, 01:44 PM -
Getting row count
By Java Tip in forum Java TipReplies: 0Last Post: 02-11-2008, 08:49 AM -
How to get Id's alone
By peiceonly in forum LuceneReplies: 1Last Post: 08-07-2007, 05:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks