JavaScript - Calculate Checkbox And Drop Down Values
I have the following code working with the checkbox options but once I added a drop down menu with values, it doesn't calculate it. I've done some different things to try to add the drop down to the function but nothing would work that I've tried so far.
I have it setup so when a box is unchecked, that option is taken off the price, the drop down should do the same to switch between the options price. Thanks for the help! Code: <script language="javascript"> totalOptions = 0; function calculateTotalOptions(thisCheckbox){ if (thisCheckbox.checked) { totalOptions += parseFloat(thisCheckbox.value); } else { totalOptions -= parseFloat(thisCheckbox.value); } document.getElementById("totalOptions").value = "$" + totalOptions + ".00"; } </script> <form name="Options" > <table width="765" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="8" align="center" bgcolor="#FFFFFF">Please select which model you would like to price and then add your optional equipment.</td> <td width="4" align="center" bgcolor="#FFFFFF"> </td> <td width="4" align="center" bgcolor="#FFFFFF"> </td> <td width="4" align="center" bgcolor="#FFFFFF"> </td> </tr> <tr> <td colspan="3" align="center" bgcolor="#FFFFFF"><strong>Available on these models</strong></td> <td width="85" align="center" bgcolor="#FFFFFF">Most Popular Options</td> <td width="97" align="center" bgcolor="#FFFFFF">Option Code</td> <td width="192" align="center" bgcolor="#FFFFFF"><strong>Optional Equipment</strong></td> <td width="61" align="center" bgcolor="#FFFFFF"><strong>Price</strong></td> <td width="149" align="center" bgcolor="#FFFFFF"><strong>Add Option</strong></td> </tr> <tr> <td width="58" align="center"><p><strong>SR 125<br /> </strong></p></td> <td width="58" align="center"><p><strong>SR 225<br /> </strong></p></td> <td width="58" align="center"><p><strong>SR 325<br /> </strong></p></td> <td colspan="5" align="right"><strong>Select Base Model: </strong> <select name="model" id="model"> <option value="0.00" selected onclick="calculateTotalOptions(this);">--------</option> <option value="-6995.00" onclick="calculateTotalOptions(this);">SR 125 Standard</option> <option value="-7495.00" onclick="calculateTotalOptions(this);">SR 125 H.D.</option> <option value="7995.00" onclick="calculateTotalOptions(this);">SR 125 S.D.</option> <option value="8495.00" onclick="calculateTotalOptions(this);">SR 225 Standard</option> <option value="8995.00" onclick="calculateTotalOptions(this);">SR 225 H.D.</option> <option value="9595.00" onclick="calculateTotalOptions(this);">SR 225 S.D.</option> <option value="9995.00" onclick="calculateTotalOptions(this);">SR 325 Standard</option> <option value="10495.00" onclick="calculateTotalOptions(this);">SR 325 H.D.</option> <option value="10995.00" onclick="calculateTotalOptions(this);">SR 325 S.D.</option> </select></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF">SR-ES</td> <td bgcolor="#FFFFFF">•Electric start </td> <td bgcolor="#FFFFFF">$345.00</td> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="t1" id="t1" value="345.00" onclick="calculateTotalOptions(this);"> </td> </tr> <tr> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"> </td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td>SR-OCP</td> <td>•Operator convience package; includes tach, hour, lube meter, hydraulic pressure gauge and bottle holder</td> <td>$125.00</td> <td align="center"><input type="checkbox" name="t1" id="t1" value="125.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"> </td> <td align="center" bgcolor="#FFFFFF"> </td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"><table cellspacing="0" cellpadding="0"> <td width="127">SR-EZM</td> </table></td> <td bgcolor="#FFFFFF">•EZ maintance hydraulic package; includes temperature and fill sight guage and quickdrain ball valve</td> <td bgcolor="#FFFFFF">$100.00</td> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="t1" id="t1" value="100.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td align="center"> </td> <td align="center"> </td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"> </td> <td><table cellspacing="0" cellpadding="0"> <td width="127">SR-6W</td> </table></td> <td>•Six way wedge with on board storage</td> <td>$495.00</td> <td align="center"><input type="checkbox" name="t1" id="t1" value="495.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"> </td> <td align="center" bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"><table cellspacing="0" cellpadding="0"> <td width="127">SR-JLL</td> </table></td> <td bgcolor="#FFFFFF">•Jointed log lift</td> <td bgcolor="#FFFFFF">$495.00</td> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="t1" id="t1" value="495.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"> </td> <td align="center"> </td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td><table cellspacing="0" cellpadding="0"> <td width="127">SR-SEGTR</td> </table></td> <td>•Segmented tire for spotting includes spotting hitch</td> <td>$350.00</td> <td align="center"><input type="checkbox" name="t1" id="t1" value="350.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"> </td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td bgcolor="#FFFFFF"><table cellspacing="0" cellpadding="0"> <td width="127">SR-MGST</td> </table></td> <td bgcolor="#FFFFFF">•Motor guard with saddle for segmented tire</td> <td bgcolor="#FFFFFF">$95.00</td> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="t1" id="t1" value="95.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td align="center"><p><img src="dot.png" alt="" width="11" height="11" /></p></td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"> </td> <td><table cellspacing="0" cellpadding="0"> <td width="127">SR-MG</td> </table></td> <td>•Motor guard w/o saddle</td> <td>$75.00</td> <td align="center"><input type="checkbox" name="t1" id="t1" value="75.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"><table cellspacing="0" cellpadding="0"> <td width="127">SR-SPRTR</td> </table></td> <td bgcolor="#FFFFFF">•Spare tire and holder</td> <td bgcolor="#FFFFFF">$250.00</td> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="t1" id="t1" value="250.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td> </td> <td><table cellspacing="0" cellpadding="0"> <td width="127">SR-HOC</td> </table></td> <td>•Hydraulic oil cooler</td> <td>$795.00</td> <td align="center"><input type="checkbox" name="t1" id="t1" value="795.00" onclick="calculateTotalOptions(this);"> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"><table cellspacing="0" cellpadding="0"> <td width="127">SR-GRLP</td> </table></td> <td bgcolor="#FFFFFF">•Grip Rightâ„¢ log points (each additional point)</td> <td bgcolor="#FFFFFF">$20.00</td> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="t1" id="t1" value="20.00" onclick="calculateTotalOptions(this);"> </td> </tr> <tr> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td> </td> <td><table cellspacing="0" cellpadding="0"> <td width="127">SR-HDF</td> </table></td> <td>•Heavy duty fenders</td> <td>$145.00</td> <td align="center"><input type="checkbox" name="t1" id="t1" value="145.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center" bgcolor="#FFFFFF"><p><img src="dot.png" alt="" width="11" height="11" /></p></td> <td align="center" bgcolor="#FFFFFF"><img src="dot.png" alt="" width="11" height="11" /></td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"><table cellspacing="0" cellpadding="0"> <td width="127">SR-LP</td> </table></td> <td bgcolor="#FFFFFF">•Light package</td> <td bgcolor="#FFFFFF">$195.00</td> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="t1" id="t1" value="195.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td align="center"><p><img src="dot.png" alt="" width="11" height="11" /></p></td> <td align="center"><img src="dot.png" alt="" width="11" height="11" /></td> <td> </td> <td><table cellspacing="0" cellpadding="0"> <td width="127">SR-38LO</td> </table></td> <td>•38" log opening *includes 2 1/2" cylinder rod </td> <td>$995.00</td> <td align="center"><input type="checkbox" name="t1" id="t1" value="995.00" onclick="calculateTotalOptions(this);"></td> </tr> <tr> <td colspan="8" align="center" bgcolor="#FFFFFF"> </td> </tr> <tr> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> <td> </td> <td> </td> <td> </td> <td><strong>TOTAL:</strong></td> <td><input type="text" id="totalOptions" readonly> </td> </tr> </table> </form> Similar TutorialsHi.I have found this nice code through forum.Now I want to modify it a little bit.But dont know how to It calculates amount column value by multiplying quantity to amount.i.e. amount=qty*rate and gross total is sum of all the array elements in amount.Here I want to add two more columns viz vat% and vat amount.Simply it will be amount*vat% / 100.Can anyone please tell me how I can do that?Other thing is, is it possible to separate the 5% vat and 12.5% vat values and display the total of them in respective column? Here is the link for reference : http://kavisandeepdwivedi.com/forum.php Please go through the code below and help me out Code: <html> <head> <script type="text/javascript"> function tot(elem) { var d=document.getElementById("total").value; var total=Number(d); var e=document.getElementById("vat5").value; var vat5=Number(e); var f=document.getElementById("vat12_5").value; var vat12_5=Number(f); var g=document.getElementById("cash_discount").value; var cash_discount=Number(g); var h=(total+vat5+vat12_5)-cash_discount; document.getElementById("grand_total").value = h; } var total = 0; function getValues() { var qty = 0; var rate = 0; var obj = document.getElementsByTagName("input"); for(var i=0; i<obj.length; i++){ if(obj[i].name == "qty[]"){var qty = obj[i].value;} if(obj[i].name == "rate[]"){var rate = obj[i].value;} if(obj[i].name == "amt[]"){ if(qty > 0 && rate > 0){obj[i].value = qty*rate;total+=(obj[i].value*1);} else{obj[i].value = 0;total+=(obj[i].value*1);} } } document.getElementById("total").value = total*1; total=0; } </script> <script type="text/javascript"> function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var colCount = table.rows[0].cells.length; for(var i=0; i<colCount; i++) { var newcell = row.insertCell(i); newcell.innerHTML = table.rows[0].cells[i].innerHTML; //alert(newcell.childNodes); switch(newcell.childNodes[0].type) { case "text": newcell.childNodes[0].value = ""; break; case "checkbox": newcell.childNodes[0].checked = false; break; case "select-one": newcell.childNodes[0].selectedIndex = 0; break; } } } function deleteRow(tableID) { try { var table = document.getElementById(tableID); var rowCount = table.rows.length; for(var i=0; i<rowCount; i++) { var row = table.rows[i]; var chkbox = row.cells[0].childNodes[0]; if (null != chkbox && true == chkbox.checked) { if (rowCount <= 1) { alert("Cannot delete all the rows."); break; } table.deleteRow(i); rowCount--; i--; } } } catch(e) { alert(e); } getValues(); } </script> </head> <body> <form name="gr" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" onSubmit="return validateForm(this)"> <tr> <td class="forhead" style="white-space:nowrap;"><input type="button" value="Add Row" onClick="addRow('dataTable')" > <input type="button" value="Delete Row" onClick="deleteRow('dataTable')" ></td> <table width="38%" align="center" cellpadding="0" cellspacing="0" class="normal-text" border="0"> <td width="20"></td> <td width="80" class="forhead" style="white-space:nowrap;">Qty</td> <td width="80" class="forhead" style="white-space:nowrap;">Rate</td> <td width="80" class="forhead" style="white-space:nowrap;">Amount</td> <td width="80" class="forhead" style="white-space:nowrap;">Vat</td> <td width="80" class="forhead" style="white-space:nowrap;">Vat Amount</td> </tr> </table> <table border="0" id="dataTable" width="38%" align="center" cellpadding="0" cellspacing="0" class="normal-text"> <tr> <td class="forhead" style="white-space:nowrap;" width="20"><input type="checkbox" name="chk[]"/></td> <td class="forhead" style="white-space:nowrap;" width="80"><input type="text" name="qty[]" onkeyup="getValues()" style="width:80px;" onBlur=""></td> <td class="forhead" style="white-space:nowrap;" width="80"><input type="text" name="rate[]" onKeyUp="getValues()" style="width:80px;" value=""></td> <td class="forhead" style="white-space:nowrap;" width="80"><input type="text" name="amt[]" style="width:80px;" onKeyUp="getValues()"></td> <td width="80" align="right" class="forhead" style="white-space:nowrap;"> <select name="vat[]" style="width:80px" onChange="getValues()"> <option value="0">Select</option> <option value="5">5</option> <option value="12.5">12.5</option> </select> </td> <td class="forhead" style="white-space:nowrap;" width="80"><input type="text" name="vat_amt[]" style="width:80px;"></td> </tr> </table> <table width="38%" align="center" cellpadding="0" cellspacing="0" class="normal-text" border="0"> <tr> <td width="20" class="forhead" style="white-space:nowrap;"> </td> <td width="80" class="forhead" style="white-space:nowrap;">Gross Total:</td> <td width="80" class="forhead" style="white-space:nowrap;"> </td> <td width="80" class="forhead" style="white-space:nowrap;"> </td> <td width="80" class="forhead" style="white-space:nowrap;"> </td> <td width="80" class="forhead" style="white-space:nowrap;"><input type="text" id="total" name="total[]" style="width:80px;" value=""></td> </tr> <tr> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;">Vat 5%:</td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"><input type="text" name="vat5[]" id="vat5" style="width:80px;"></td> </tr> <tr> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;">Vat 12.5%:</td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"><input type="text" name="vat12_5[]" id="vat12_5" style="width:80px;"></td> </tr> <tr> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;">Cash Dis :</td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"><input type="text" id="cash_discount" name="cash_discount[]" style="width:80px;" value=""></td> </tr> <tr> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;">Total :</td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"> </td> <td class="forhead" style="white-space:nowrap;"><input type="text" name="grand_total" id="grand_total" onKeyUp="tot()" style="width:80px;"></td> </tr> <tr> <td align="center" colspan="6"> <input name="Submit" type="submit" value="Save" style="text-decoration:none"/> <input type="reset" value="Cancel" onClick="window.location.href='<?php echo $_SERVER['PHP_SELF'];?>'"> </td> </tr> </table> </td> </tr> </table> </td> </tr> </form> </body> </html> I have a bunch of checkboxes like below that the user can check some or all and click the button and see the values of all the selected checkboxes. How can I do that? Code: <script> function alertValues(){ } </script> <input type="checkbox" class ="normal2" value="131971" name="list[]" > <input type="checkbox" class ="normal2" value="131973" name="list[]" > <input type="checkbox" class ="normal2" value="131975" name="list[]" > <input type="checkbox" class ="normal2" value="131977" name="list[]" > <input type="button" onClick="alertValues()" I have tried many time to make the calculation to appear at the total text box. however, I fail to find where the problem is. Please help me.. here is my coding.. <html> <head> <title> PRESENTATION EVALUATION FORM </title></head> <style type="text/css"> .style1 { text-align: center; } </style> <script type="text/javascript"> function add($g1,$g2,$g3,$g4,$g5,$g6,$g7,$g8,$g9,$g10,$g11,$g12,$g13) { $g1=$_POST['document.myForm.gred1.value']; $g2=$_POST['gred3.value']; $g3=$_POST['gred3.value']; $g4=$_POST['gred4.value']; $g5=$_POST['gred5.value']; $g6=$_POST['gred6.value']; $g7=$_POST['gred7.value']; $g8=$_POST['gred8.value']; $g9=$_POST['gred9.value']; $g10=$_POST['gred10.value']; $g11=$_POST['gred11.value']; $g12=$_POST['gred12.value']; $g13=$_POST['gred13.value']; $total=$g1+$g2+$g3+$g4+$g5+$g6+$g7+$g8+$g9+$g10+$g11+$g12+$g13; } </script> <body> <center><img src="logo.gif" height="200" weight="240"></center> <p><center><b>FAKULTI SISTEM KOMPUTER & KEJURUTERAAN PERISIAN<br>UNIVERSITI MALAYSIA PAHANG</b></center></p> <table width="100% "border="1"> <form name="myForm" method="post"> <tr> <th style="width: 447px">ITEM</th> <th style="width: 340px">SCORE</th> </tr> <tr> <td style="width: 447px"> A) SLIDES</td> <td style="width: 340px"> </td> </tr> <tr> <td style="width: 447px"> i. Use of Diagram and Animations </td> <td style="width: 340px" class="style1"> <select name="gred1" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </tr> <tr> <td style="width: 447px"> ii. Layout, Font and Color (Readable, Consistent, Attractive) </td> <td style="width: 340px" class="style1"> <select name="gred2" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </tr> <tr> <td style="width: 447px"> iii. Content Structure</td> <td style="width: 340px" class="style1"> <select name="gred4" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select></td> </tr> <tr> <td style="width: 447px; height: 28px;"> iv. Slide Content</td> <td style="width: 340px; height: 28px;" class="style1"> <select name="gred3" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select></tr> <tr> <td style="width: 447px"> B) PRESENTATION</td> <td style="width: 340px"></td> </tr> <tr> <td style="width: 447px"> i. Explaining and Not Reading The Slides </td> <td style="width: 340px" class="style1"> <select name="gred5" onchange="add()" style="width: 45px; height: 22px;"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </tr> <tr> <td style="width: 447px"> ii. Voice, Eye Contact and Gestures</td> <td style="width: 340px" class="style1"> <select name="gred6" onchange="add()" style="width: 45px; height: 22px;"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </tr> <tr> <td style="width: 447px"> iii. Capture Audience Interest</td> <td style="width: 340px" class="style1"> <select name="gred7" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </tr> <tr> <td style="width: 447px"> iv. Proper Introduction and Closing</td> <td style="width: 340px" class="style1"> <select name="gred8" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select></td> </tr> <tr> <td style="width: 447px"> C) LANGUAGE</td> <td style="width: 340px" class="style1"> </tr> <tr> <td style="width: 447px"> i. Fluency </td> <td style="width: 340px" class="style1"> <select name="gred9" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select></td> </tr> <tr> <td style="width: 447px"> ii. Correctness</td> <td style="width: 340px" class="style1"> <select name="gred10" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </tr> <tr> <td style="width: 447px"> iii. English Vocabulary</td> <td style="width: 340px" class="style1"> <select name="gred11" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </tr> <tr> <td style="width: 447px"> D) QUESTION AND ANSWER HANDLING</td> <td style="width: 340px" class="style1"> </tr> <tr> <td style="width: 447px"> i. Confidence</td> <td style="width: 340px" class="style1"> <select name="gred12" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </tr> <tr> <td style="width: 447px"> ii. Logic Responds</td> <td style="width: 340px" class="style1"> <select name="gred13" onchange="add()" style="width: 45px"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </tr> <tr> <td style="width: 447px; height: 27px;"><center><b>Total</b></center></td> <td style="width: 340px; height: 27px;"><center> <input name="totalmark" type="text" style="width: 52px" value="0" > <?php echo $_POST["$total"];></center></td> </table> <table> <tr> <td class="style1" style="width: 802px"><br><input type="button" name="total" value="CALCULATE" onclick= "add()"> <input type="RESET" value="RESET"></td> </tr> </form> </table> </body> </html> I am having trouble with figuring a way to set my loop up to reset values of the different coin values. Example, when I put in 78, and click calculate, it tells you how much of each coin would be given back. My problem is that I set it up and run it, but when I put different values in back to back to calculate, some of the fields don't reset. I just need some ideas or logic behind what I need to do. Code: var change_out = function(){ do { var money = document.getElementById("cents").value; if (money >= 25) { var quarters = parseInt(money / 25); var foo = parseInt(money - (quarters * 25)); document.getElementById("quarters").value = quarters; if (foo >= 10) { var left = parseInt(foo / 10); var wow = parseInt(foo - (left * 10)); document.getElementById("dimes").value = left; if(wow==0)return; if (wow >= 5) { var dumb = parseInt(wow / 5); var pop = parseInt(wow - (dumb * 5)); document.getElementById("nickels").value = dumb; document.getElementById("pennies").value = pop; }else{document.getElementById("pennies").value = wow;} }else if (foo >= 5){ var dumb = parseInt(foo / 5); var pop = parseInt(foo - (dumb * 5)); document.getElementById("nickels").value = dumb; document.getElementById("pennies").value = pop; }else{document.getElementById("pennies").value = foo;} }else if (money >= 10){ var left = parseInt(money / 10); var wow = parseInt(money - (left * 10)); document.getElementById("dimes").value = left; if (wow > 5){ var dumb = parseInt(wow / 5); var pop = parseInt(wow - (dumb * 5)); document.getElementById("nickels").value = dumb; document.getElementById("pennies").value = pop; document.getElementById("quarters").value = ""; }else{document.getElementById("pennies").value = wow;} }else if (money >= 5){ var dumb = parseInt(money / 5); var pop = parseInt(money - (dumb * 5)); document.getElementById("nickels").value = dumb; document.getElementById("pennies").value = pop; document.getElementById("quarters").value = ""; document.getElementById("dimes").value = ""; }else{ document.getElementById("pennies").value = money; document.getElementById("quarters").value = ""; document.getElementById("dimes").value = ""; document.getElementById("nickels").value = ""; } }while(isNaN(money))} Need help please asap. It might be simple but i couldn't work out the script. help! ---------------- Formfield.anzahl1 = number entered by customer Formfield.Price1 = Ergebnisfeld1 e.g. Anzahl1= 1 Price = 270 *if Anzahl1 = 2 then Price = 270*2 I need to do this for two form option. 2nd field would be as follows Formfield.Anzahl2= number entered by customer Formfield.Price2 = Ergebnisfeld2 Then Formfield.Total = Ergebnisfeld1 + Ergebnisfeld2 ------------------- How can I convert these above to javascript? Hi all, I'm very new to Javascript and wonder if someone can help me. I'm creating an online enrolment form for my company, who are a training company. Users enrolling on the course must make three choices - The level of course, the size of course and whether they wish to attend a workshop or study by distance learning. The combination of these three factors will determine the price. I'd like to have the price automatically calculated using javascript and displayed on the form before they submit. Can anyone give me an idea of how to do this? There are three drop down boxes for users to select their course. They a - Level of Qualification: Level 3 Level 4 Level 5 Level 6 Scale of Qualification: Award Certificate Diploma Preferred Delivery Method Workshop Distance Learning Each possible combination of these will affect the price. So for instance, if the user were to select 'Level 4', 'Certificate' and 'Workshop' the price would be calculated based on these three options. How can I calculate the ultimate price and then display it on the page (I was thinking of using innerHTML in a 'span' element to display the final value, but if anyone has any better ideas I'd be glad to hear them) The HTML code for the drop down boxes is below: Code: <form action="enrolment.php" method="post"> <select name="level" class="input" id="level"> <option value="chooselevel"></option> <option value="Level 3">Level 3</option> <option value="Level 4">Level 4</option> <option value="Level 5">Level 5</option> <option value="Level 6">Level 6</option> </select> <select name="size" class="input" id="size"> <option value="choosesize"></option> <option value="Award">Award</option> <option value="Certificate">Certificate</option> <option value="Diploma">Diploma</option> </select> <select name="delivery" class="input" id="deliv"> <option value="deliverymethod"></option> <option value="Workshop">Workshop</option> <option value="Distance Learning">Distance Learning</option> </select> </form> Thanks all, hope someone here can help! Regards Chris *EDIT: I should mention that the form is also inside a table - Not sure if that will make a difference. My goal is that when I click on the submit button, I just want to display an alert box with the values selected, and also look at this in the console.log. Can anyone help me? Thanks. Code: <html> <head> </head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(init); function init() { $ ("#t").submit(function() { var g = showCheckedValues(); console.log(g); alert(g); }); function showCheckedValues() { // Gather all values of checked checkboxes with name "bedrooms". var checked = $('input[name=bedrooms]:checked').map(function() { return this.value; }).get(); }} </script> <body> <form id="t"> <input type="checkbox" name="bedrooms" value="1">1 bedroom<br> <input type="checkbox" name="bedrooms" value="2">2 bedroom<br> <input type="checkbox" name="bedrooms" value="3">3 bedroom<br> <input type="checkbox" name="bedrooms" value="4+">4+ bedroom<br> <input type="submit" name="save-changes"></input> </form> </body> </html> I have a page where a user can select (via check boxes) several categories. Each category is related to a set of possible options (radio buttons) that have numeric values. When one of the options (radio button) is selected, the amount will appear in a text box (input type="text"). The numeric value in the text box will update depending on what category options are selected. However, when the checkbox is deselected, the radio boxes in the <div> are not displayed and I need to remove (reset) the radio button values from the value seen in the text box. Here are some snippets to hopefully expound on what I would like to do. Code: <script type="text/javascript"> var amountNotice = 0; function notice(options) { amountNotice = parseInt(options); calculateTotal(); } function calculateTotal() { totalAmount = amountNotice; document.getElementById("total").value = totalAmount.toFixed(2); } function toggle(chkbox, group, associatedValues) { var visSetting; if (chkbox.checked == true) document.getElementById(group).style.display = "inline"; else { document.getElementById(group).style.display = "none"; uncheckRadio(associatedValues); } document.getElementById(group).style.display = visSetting; } function uncheckRadio(associatedValues) { for(var i = 0; i < document.getElementById(associatedValues).length; i++) { if (associatedValues[i].checked == true) associatedValues[i].checked == false; } calculateTotal(); } </script> <style type="text/css"> #groupNotice {display: none} </script> . . <input type="button" onClick="calculateTotal()" value="Calculate"><br> <div id="groupNotice"> <b>Required Notice</b>: <input type="radio" name="Note" onClick="notice(this.value)" value="0"> None <input type="radio" name="Note" onClick="notice(this.value)" value="2"> Prior Day ($2) <input type="radio" name="Note" onClick="notice(this.value)" value="2"> Prior Call ($2)<br> </div> <form name="CostEstimate" method="post" action="calculator.php"> <input type="checkbox" onclick="toggle(this, 'groupNotice', 'Note'); display('groupNotice','inline')" name="Notice" value=""> Notice </form> Everything works except for my uncheckRadio function - not sure if I am identifying the elements correctly, or if I need a totally new approach. My thinking is that the function must be accessed by the checkbox onClick call. Previously I had tried calling uncheckRadio from the notice function before I recognized is was not an appropriate location. Any assistance is greatly appreciated. - c Hi all, I am in the process of developing a calculator for some of my colleagues to use. One of the variables within the calculations is called PMH. I want to determine the value of PMH based on which checkboxes are ticked. Each checkbox has a different value. If the checkbox is not ticked, then the value of each option is 1 and obviously more than one checkbox may be ticked. I have created the checbox code: Code: <td><input type="checkbox" name="PMH" value="1.6" /> Smoker<br /> <input type="checkbox" name="PMH" value="0.4" /> CCF<br /> <input type="checkbox" name="PMH" value="0.5" /> Pulmonary Oedema / Cirrhosis<br /> <input type="checkbox" name="PMH" value="0.8" /> COAD<br /></td> but I have no idea on how to calculate what I need for var PMH. Can someone guide me as to what I need to do please? Cheers, mads Pardon my rookie question as I know little about code, but have managed with some help to get a basic setup of what I want, just not quite the end product. I have a pricing page that is broken into multiple categories per phase. I want a customer to be able to select my checkboxes and hit a button that will display a rolled up total. I also want it to be able to re-calculate the totals if a box is subsequently unchecked. I have browsed and searched the form to get the code to where it is now but need help to finish it. Thank you in advance, Here is a bit of the code I am using so you have an example" Code: <div class="item"> <h1>Phase 1: Structurals</h1> </div> <input name="Phase 1" type="checkbox" value="0~~Phase 1: Complete w/ Engineering" /> Phase 1: Complete w/ Engineering <input name="Phase 1" type="checkbox" value="0~~Phase 1: Complete w/ Out Engineering" /> Phase 1: Complete w/ Out Engineering <input name="Phase 1" type="checkbox" value="10~~Foundation: Monoslab" /> Foundation: Monoslab <input name="Phase 1" type="checkbox" value="20~~Foundation: Post Tension" /> Foundation: Post Tension <input name="Phase 1" type="checkbox" value="30~~Foundation: Stemwall" /> Foundation: Stemwall <input name="Phase 1" type="checkbox" value="40~~Foundation: Basement" /> Foundation: Basement <input name="Phase 1" type="checkbox" value="40~~Framing w/ Engineering" /> Framing w/ Engineering <input name="Phase 1" type="checkbox" value="40~~Framing w/ out Engineering" /> Framing w/ out Engineering <input name="Phase 1" type="checkbox" value="40~~Framing Hardware (with Engineering ONLY)" /> Framing Hardware (with Engineering ONLY) <div class="item"> <h1>Phase 2: Mechanicals</h1> </div> <input name="Phase 2" type="checkbox" value="0~~Phase 2: Complete w/ Engineering" /> Phase 2: Complete w/ Engineering <input name="Phase 2" type="checkbox" value="0~~Phase 2: Complete w/ Out Engineering" /> Phase 2: Complete w/ Out Engineering <input name="Phase 2" type="checkbox" value="10~~Plumbing" /> Plumbing <input name="Phase 2" type="checkbox" value="20~~HVAC" /> HVAC <input name="Phase 2" type="checkbox" value="30~~Electrical" /> Electrical <div class="item"> <h1>Phase 3: Exterior Finishes</h1> </div> <input name="Phase 3" type="checkbox" value="0~~Phase 3: Complete" /> Phase 3: Complete <input name="Phase 3" type="checkbox" value="0~~Housewrap" /> Housewrap <input name="Phase 3" type="checkbox" value="10~~Brick" /> Brick <input name="Phase 3" type="checkbox" value="20~~Stone" /> Stone <input name="Phase 3" type="checkbox" value="30~~Vinyl Siding" /> Vinyl Siding <input name="Phase 3" type="checkbox" value="30~~Cementitious Siding" /> Cementitious Siding <input name="Phase 3" type="checkbox" value="30~~Roofing" /> Roofing <input name="Phase 3" type="checkbox" value="30~~Windows" /> Windows <input name="Phase 3" type="checkbox" value="30~~Exterior Doors" /> Exterior Doors <div class="item"> <h1>Phase 4: Interior Finishes</h1> </div> <input name="Phase 4" type="checkbox" value="0~~Phase 4: Complete" /> Phase 4: Complete <input name="Phase 4" type="checkbox" value="0~~Insulation" /> Insulation <input name="Phase 4" type="checkbox" value="10~~Drywall" /> Drywall <input name="Phase 4" type="checkbox" value="20~~Paint" /> Paint <input name="Phase 4" type="checkbox" value="30~~Interior Trim" /> Interior Trim <input name="Phase 4" type="checkbox" value="30~~Interior Doors" /> Interior Doors <input name="Phase 4" type="checkbox" value="30~~Mirrors" /> Mirrors <input name="Phase 4" type="checkbox" value="20~~Shelving" /> Shelving <input name="Phase 4" type="checkbox" value="30~~Bath Accessories" /> Bath Accessories <input name="Phase 4" type="checkbox" value="30~~Countertops" /> Countertops <input name="Phase 4" type="checkbox" value="30~~Cabinets" /> Cabinets <input name="Phase 4" type="checkbox" value="30~~Shower Surrounds" /> Shower Surrounds <input name="Phase 4" type="checkbox" value="30~~Shower Enclosures" /> Shower Enclosures <div class="item"> <h1>Phase 5: Flooring</h1> </div> <input name="Phase 5" type="checkbox" value="0~~Flooring" /> Flooring Hi, here is what I am trying to do, mind if I sound simple this is my first major javascript attempt. You click the checkbox and it changes a link. You click the checkbox again and it changes it back. So you have a page with a link : <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RSNVHTY5D6RN" id="pay"><img src="go.gif"></a> and a checkbox : <a nohref style="cursorointer;color:blue;text-decoration:underline" onclick="changeTarget()"><input type="checkbox" OnClick="changeTarget()" checked="yes" name="opt-in" id="opt-in" align="center" /></a> </p> Clicking the checkbox runs the javascript function ChangeTarget(). Here is what I want the javascript to do: Code: 1. Write current pay value to variable 2. Compare variable to paypal link -3. change to clickbank link -else change to paypal link. Here is the code I have tried that doesnt work: Code: <script type="text/javascript"> var link = document.getElementById('pay'); function changeTarget() if(link == "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RSNVHTY5D6RN") document.getElementById('pay').href="http://1.60years.pay.clickbank.net"; else document.getElementById('pay').href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RSNVHTY5D6RN"; </script> Any help would be very much appreciated, I don't know why it isnt working. It just doesnt do anything when you click it. I know the following DOES work, but it only changes the link to the value chosen... no way of changing it back when you click the checkbox a second time. Code: //WORKING CODE <script type="text/javascript"> function changeTarget() { document.getElementById('pay').href="http://1.60years.pay.clickbank.net"; } </script> I was wondering if anyone could help me with getting this working. I'm using html to create a table which has at least 1 row but no max number of rows - as they can be added/removed by the user - and 4 columns, 1st contains a checkbox and the last 2 contain drop down menus. I wish to be able to store the values of those menus in an array only if that row's checkbox has been checked. e.g if the first row has 1 and A as it's dropdown values and the second row has 2 and B. If only row 1 has been checked the array should only contain [1,A]. Instead mine holds all the values including the non-checked ones i.e [1,A,2,B]. My code for javascript function and html table are below: Code: function calculate(textID){ var table = document.getElementById('course'); //id of table var rowCount = table.rows.length; var array = []; //array to hold the values var c = 0; dmenus = document.getElementByTagName("select"); //get the drop down menus for(var a = 1; a < rowCount; i++){ //a = 1 as the 1st row contains column headings var row = table.rows[a]; var check = row.cells[0].childNodes[0]; if(null != check && true == check.checked){ for(var b = 0; b < dmenus.length; b++){ val = dmenus[b].options[dmenus[b].selectedIndex].value; array[c] = val; //set index of array to equal value of dropdown box c++; } }else{ b++; } } Html code for table: Code: <table id="course"> <tr> <td><input type="checkbox" name="ucheck" id="ucheck" onclick="checkAll('course')"/></td> <th style="color:white">Course Title</th> <th style="color:white">Credits</th> <th style="color:white">Grade</th> </tr> <tr> <td><input type="checkbox" name="tick" id="tick"/></td> <td><input type="text"/></td> <td> <select name="credits" id="credits"> <option...</select></td> <td> <select name="grade" id="grade"> <option...</td> It works only for the first row but if there are more than 1 row it doesn't do what it's supposed to. The coding platform I'm working on does not seem to support jquery so javascript code will be most appreciated. Thanks i'm trying to "post" the selected checkboxes (name and value) into a mysql database; i've search "docter google" for some answers and read that the "easiest" way to do this is to collect the checkboxes and put the values and names in to an hidden textfield ( function setvalue() ) and collect this textfield in a new page with php; but this doesn't work. it seems that the variable naamtest is empty (when i load a word into this var arv it does work) can someone find my error? Code: <script type="text/javascript"> function shift(which) { var counter = 0; // counter for checked checkboxes var i = 0; // loop variable var veck = "";// final url variable var beginsaldo = 79; var namen_array = ""; var va_array = ""; var namen = ""; var valu = ""; var input_obj = document.getElementsByTagName('input'); // get a collection of objects with the specified 'input' TAGNAME for (i=0; i < input_obj.length; i++){ // loop through all collected objects if (input_obj[i].type == 'checkbox' && input_obj[i].checked == true){ // if input object is checkbox and checkbox is checked then ... counter++; // ... increase counter var valcheck = input_obj[i].value; // waarde van de geselecteerde checkbox in variable steken test = Number(valcheck); // absolute rekenwaarde van variable maken beginsaldo -= test; //beginsaldo verminderen met de checkbox value if (counter > 0){ var naam = input_obj[i].name + ' '; var val = input_obj[i].value + ' '; namen = namen + naam; valu = valu + val; namen_array = namen.split(" "); va_array = valu.split(" "); var naamtest = namen_array; }}} if (counter > 10){ alert ("u mag maar 10 renners selecteren"); var tr = which.parentNode; while ( tr.tagName.toUpperCase() != "TR" ) { tr = tr.parentNode; if ( tr == null ) return; // something went very wrong! } var tds = tr.getElementsByTagName("td"); tds[0].getElementsByTagName("input")[0].checked = false; } else if (beginsaldo < 0){ alert ("uw saldo is te laag om dit uit te voeren"); var tr = which.parentNode; while ( tr.tagName.toUpperCase() != "TR" ) { tr = tr.parentNode; if ( tr == null ) return; // something went very wrong! } var tds = tr.getElementsByTagName("td"); tds[0].getElementsByTagName("input")[0].checked = false; } else{ var tr = which.parentNode; while ( tr.tagName.toUpperCase() != "TR" ) { tr = tr.parentNode; if ( tr == null ) return; // something went very wrong! } var tds = tr.getElementsByTagName("td"); if ( tds[0].getElementsByTagName("input")[0] == which ) { tds[2].innerHTML = tds[0].innerHTML; tds[0].innerHTML = " "; tds[3].innerHTML = tds[1].innerHTML; tds[1].innerHTML = " "; tds[2].getElementsByTagName("input")[0].checked = true; } else { // this code is optional!! tds[0].innerHTML = tds[2].innerHTML; tds[2].innerHTML = " "; tds[1].innerHTML = tds[3].innerHTML; tds[3].innerHTML = " "; tds[0].getElementsByTagName("input")[0].checked = false; } function setValue() { var arv = naamtest.join(); // This line converts js array to String document.f2.arv.value=arv; // This sets the string to the hidden form field. }}} </script> Hi, i feel kinda stupid asking this, but im kinda lost. I want to add up multiple values of groups of checkboxes. I managed to add up the values, but making it so that only one checkbox per group can be enabled at any time gives me a headache. Here is what i got so far, any hints to how to make it work would be really cool. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="PSPad editor, www.pspad.com"> <title></title> </head> <body> <script type="text/javascript"> function Summe() { sum = 0; if(document.Formular.m1.checked) { sum = sum + (1 * document.Formular.m1.value); } if(document.Formular.m2.checked) { sum = sum + (1 * document.Formular.m2.value); } if(document.Formular.m3.checked) { sum = sum + (1 * document.Formular.m3.value); } if(document.Formular.m4.checked) { sum = sum + (1 * document.Formular.m4.value); } if(document.Formular.m5.checked) { sum = sum + (1 * document.Formular.m5.value); } if(document.Formular.m6.checked) { sum = sum + (1 * document.Formular.m6.value); } if(document.Formular.m7.checked) { sum = sum + (1 * document.Formular.m7.value); } if(document.Formular.m8.checked) { sum = sum + (1 * document.Formular.m8.value); } document.Formular.black.value = sum; } </script> <form name="Formular"> <INPUT TYPE="TEXTBOX" NAME="black" VALUE="" SIZE="3"> <br> grp1<br> <input type="checkbox" Name="m1" Value="411" id="411" onClick="javascript:Summe()"> <br> <input type="checkbox" Name="m2" Value="412" id="412" onClick="javascript:Summe()"> <br><br> grp2<br> <input type="checkbox" Name="m3" Value="421" id="421"onClick="javascript:Summe()"> <br> <input type="checkbox" Name="m4" Value="422" id="422"onClick="javascript:Summe()"> <br> <input type="checkbox" Name="m5" Value="423" id="423" onClick="javascript:Summe()"> <br> <br> grp3 <br> <input type="checkbox" Name="m6" Value="431" id="431" onClick="javascript:Summe()"> <br> <input type="checkbox" Name="m7" Value="432" id="432" onClick="javascript:Summe()"> <br> <input type="checkbox" Name="m8" Value="433" id="433" onClick="javascript:Summe()"> <br> <br> </form> </body> </html> print "<Font face=\"calibri, Arial\"><table id=\"rnatable\" border=2px width=100%>"; print "<th></th>"; print "<th>a</th>"; print "<th>b</th>"; print "<th>c</th>"; print "<th>d</th>"; print "<th>e</th>"; print "<th>f</th>"; print "<th>g</th>"; while($array = mysql_fetch_array($sql_query)) { $id=$array['a']; print "<tr id=\"newtr\">"; print "<td><input id=\"check\" type=\"checkbox\" name=\"keyword[]\" value=\"$id\" ></td>"; print "<td>".$array['a']."</td>"; print "<td>".$array['b']."</td>"; print "<td>".$array['c']."</td>"; print "<td>".$array['d']."</td>"; print "<td>".$array['e']."</td>"; print "<td>".$array['f']."</td>"; print "<td> <a href=\"http://localhost/rnasearch/retrieve.php?a=$id\">bla</a> </td></tr></font>"; } print "</table>"; } this is part of a php searchengine script that i wrote to retrieve data from a database and as you can see the last column that is g contains a link which when clicked takes the user to the second php script which retrieves additional information of that entry, but this is done for only single entries so as you can see i introduced checkboxes so that the user can check any number of checkboxes and retrieve information as per their wish now to do this i created a <input type=text where i want the value of these checkboxes i.e. $id to be posted in a delimited format so that the user can then click the corresponding button and retrieve the information this is the code <div id="floatMenu"> <ul class="menu1"> <center><li><form name="senddata" method="POST" action="http://localhost/retrieve.php" style="display:inline;"><input id="fasta" type="text" class="multitext"><input name="Fasta" type="Submit" value="Retrieve Fasta"></form> this is a css floating menu....so far so good....everything went fine.... after this i had to write a javascript to do this and i've been stuck there searching forums for the last 4 days! this is the javascript i found from somewhere which came close to doing wht i wanted it to do window.onload = function () { var cb = document.getElementById('check'); var fasta = document.getElementById('fasta'); cb.onclick = function () {fasta.value = cb.value + ","; };}; this script only sends the value of the first checkbox in the table, the others are not found by it, mind you its not the first checkbox selected its the first checkbox that is present in the table how can i resolve this problem so that even if i have n number of checkboxes in my table, if the user chooses to do so they can retrieve n number of information....please help i've almost lost hope in this! Hi guys, i'm trying to develop a code for my sister, i would like to use javascript to finish off the following task: 1. I want to be able to select marks from 0 to 30, from 5 drop down boxes. 2. and as marks are selected, it should upgrade the total. 3. and then show me the total marks when finished. i've got up to creating the drop down boxes, now it's just adding the values once selected. Thanks! anyhelp would be welcome hi, i am currently working on aptana stuidio Nokia WRT to create a mobile widget. the projects requires the retrieval of data from a database. I've created a java servlet in eclipse to connect and execute query to the database. In aptana, i'm using js file and html file. i am able to connect to the servlet, process the data (split it) and store in an array to display the retrieved data on screen. But now i am facing problems to put the retrieved data (array) into a drop down list for selection. can i do it in a js file? thanks =) Hi, I doing my project in Netbeans, and I have this .java page, that sets and gets a html form where there are textboxes and drop down lists, as far as I know, although getElementById() is a javascript code, it can be used in my .java page, but I do not know how to implement it. What I'm supposed to do is to get the values from the drop down list and save them to a database that I've already have. Code: HtmlPage page = null; page.getElementById(id); but because I do not know what should the id be since the .java page is not a jsp page and the drop down list values cannot be retrieved directly. Need help here, thanks. |