count checkboxes

Reply

Join Date: Sep 2009
Posts: 4
Reputation: venus_me11 is an unknown quantity at this point 
Solved Threads: 0
venus_me11 venus_me11 is offline Offline
Newbie Poster

count checkboxes

 
0
  #1
Sep 23rd, 2009
i have a code here where a user can search a specific trip and can choose his/her preferred seat..
my problem is when computing the total fee for the reservation being made, i can't count the number of times a user check a seat...

by the way, the output for the total fee will be posted in another page..

pls.. help me.. tnx in advance

i know it's a long code

  1. <?php
  2.  
  3. include_once('functions.php');
  4. include_once('database.php');
  5.  
  6. $database = new Database();
  7. $database->Connect();
  8.  
  9.  
  10. $BusCode = "Type1";
  11.  
  12. // select Generator
  13. $values = array();
  14. $values[] = "DepartureName";
  15. $sql = "SELECT * FROM departure";
  16. $rs = $database->executeQuery($sql);
  17. $DepartureList = selectGenerator($rs, "DepartureID", "DepartureID", $_POST['DepartureID'], $values);
  18. // End
  19.  
  20. // select Generator
  21. $values = array();
  22. $values[] = "DestinationName";
  23. $sql = "SELECT * FROM destination";
  24. $rs = $database->executeQuery($sql);
  25. $DestinationList = selectGenerator($rs, "DestinationID ", "DestinationID", $_POST['DestinationID_'], $values);
  26. // End
  27.  
  28. if ($_POST) {
  29.  
  30. if ($_POST['cancel'] == 'Cancel') {
  31. header("Location:bus1.php");
  32. }
  33.  
  34. //$sql = "INSERT INTO "; - ung sa bus type
  35. if ($_POST['reserve'] == "reserve") {
  36.  
  37. $query = "SELECT * FROM route INNER JOIN buslist ON buslist.BusListID = route.BusListID
  38. INNER JOIN bustype ON bustype.BusTypeID = buslist.BusTypeID
  39. INNER JOIN departure ON departure.DepartureID = route.FromDest
  40. INNER JOIN destination ON destination.DestinationID = route.ToDest WHERE
  41. route.FromDest = {$_POST['DepartureID']} AND route.ToDest = {$_POST['DestinationID_']}
  42. AND route.DepartureDate = '{$_POST['DepartureDate']}' AND bustype.BusTypeID = {$_POST['BusTypeID']}";
  43.  
  44. $rs = $database->executeQuery ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
  45. if (mysql_num_rows($rs) > 0) {
  46. $rw = mysql_fetch_array($rs);
  47. $RouteID = $rw["RouteID"];
  48. }
  49.  
  50. if ($rw["BusTypeDesc"] == 'BusType2' ) {
  51. header("Location:bus2.php?RouteID={$RouteID}&ShowSeat=1&DepartureID={$_POST['DepartureID']}&DestinationID={$_POST['DestinationID_']}&DepartureDate={$_POST['DepartureDate']}");
  52. } else {
  53. header("Location:bus1.php?RouteID={$RouteID}&ShowSeat=1&DepartureID={$_POST['DepartureID']}&DestinationID={$_POST['DestinationID_']}&DepartureDate={$_POST['DepartureDate']}");
  54. }
  55.  
  56. //$RecordFound = true;
  57.  
  58. }
  59. // sa seats
  60. if ($_POST['submit'] == "Reserve") {
  61.  
  62.  
  63. foreach($_POST AS $field => $value) {
  64. //echo "field = $field, value = $value";
  65. if ($field != "submit") {
  66. $sql = "INSERT INTO reservation (ClientID, RouteID, BusTypeCode, SeatNo, IsPaid, AmountPaid) VALUES
  67. (2, {$_REQUEST['RouteID']}, '{$BusCode}', {$value}, 0, 0)";
  68.  
  69. $database->executeNonQuery($sql);
  70. //echo $sql;
  71. //redirect
  72. header("Location:passenger_fillup.php");
  73. }
  74. }
  75.  
  76. }
  77.  
  78. if ($_POST['Search'] == "search") {
  79.  
  80. //Check are taken from reservation
  81. $query = "SELECT * FROM route INNER JOIN buslist ON buslist.BusListID = route.BusListID
  82. INNER JOIN bustype ON bustype.BusTypeID = buslist.BusTypeID
  83. INNER JOIN departure ON departure.DepartureID = route.FromDest
  84. INNER JOIN destination ON destination.DestinationID = route.ToDest
  85. WHERE
  86. route.FromDest = {$_POST['DepartureID']} AND route.ToDest = {$_POST['DestinationID_']}
  87. AND route.DepartureDate = '{$_POST['DepartureDate']}'";
  88.  
  89. $rs = $database->executeQuery ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
  90.  
  91.  
  92. if (mysql_num_rows($rs) > 0) {
  93. $result = "<center><br><b><font color=\"#FFFFFF\">" . mysql_num_rows($rs) . " record(s) found</center></font></b>";
  94.  
  95. $sql = "SELECT * FROM buslist INNER JOIN bustype ON buslist.BusTypeID = bustype.BusTypeID
  96. WHERE BusListID = ";
  97. while($rw = mysql_fetch_array($rs)){
  98. $sql .= $rw['BusListID'] . " AND BusListID = ";
  99. // Select avaiable bus BusListID
  100. }
  101.  
  102. $sql = substr($sql, 0, (strlen($sql)-17));
  103. $values = array();
  104. $values[] = "BusTypeDesc";
  105. $rs = $database->executeQuery($sql);
  106. $SearchResultBusList = selectGenerator($rs, "BusTypeID", "BusTypeID", $_POST['BusTypeID'], $values);
  107.  
  108. $result .= "<br>";
  109. $result .= $SearchResultBusList;
  110.  
  111. } else {
  112. //$result = "
  113. // <center><b>No records found</b></center>
  114. // ";
  115. $result= "
  116. <center><b>No records found</b></center>";
  117.  
  118.  
  119. }
  120.  
  121. }
  122.  
  123.  
  124. //$_POST['DepartureDate'] = date("m/d/y");
  125.  
  126.  
  127. } else {
  128.  
  129. if ($_REQUEST['RouteID']!="") {
  130.  
  131. // Check list of reservation
  132. $sql = "SELECT * FROM reservation WHERE RouteID = {$_REQUEST['RouteID']} AND BusTypeCode = 'Type1'";
  133. $rs = $database->executeQuery ($sql) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
  134. if (mysql_num_rows($rs) > 0) {
  135. // filter the one with reservation
  136. // para ung checkbox and color.. maalis
  137. $s = array();
  138. $c = array();
  139. while($rw = mysql_fetch_array($rs)){
  140. //echo "here";
  141. for ($x=1; $x<40; $x++) {
  142. if ($rw['SeatNo'] == $x) {
  143. $s[$x] = " disabled";
  144. $c[$x] = "style=\"background-color:#cc3333;\"";
  145. }
  146. }
  147.  
  148. }
  149. }
  150.  
  151. }
  152.  
  153. //echo "<pre>";
  154. //print_r($c);
  155. //echo "</pre>";
  156. }
  157.  
  158.  
  159. $database->Disconnect();
  160. ?>
  161. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  162. <html>
  163. <head>
  164. <script language="JavaScript" src="gen_validatorv31.js" type="text/javascript"></script>
  165.  
  166. <Style>
  167. BODY, P,TD{ font-family: Arial,Verdana,Helvetica, sans-serif; font-size: 10pt }
  168. A{font-family: Arial,Verdana,Helvetica, sans-serif;}
  169. B { font-family : Arial, Helvetica, sans-serif; font-size : 12px; font-weight : bold;}
  170. </Style>
  171.  
  172. <link rel="stylesheet" type="text/css" media="all" href="jsDatePick.css">
  173. <script type="text/javascript" src="jsDatePick.min.1.0.js"></script>
  174. <script type="text/javascript">
  175. window.onload = function(){
  176. new JsDatePick({
  177. useMode:2,
  178. target:"inputField"
  179. //limitToToday:true <-- Add this should you want to limit the calendar until today.
  180. });
  181. };
  182. </script>
  183. <script language="JavaScript">
  184. var bgcolorSelected = "#cc3333";
  185. var bgcolorNotSelected = "black";
  186.  
  187. function HighLightTR1(el){
  188. if (document.myform.s1.checked == true) {
  189. el.bgColor=bgcolorSelected;
  190. } else {
  191. el.bgColor=bgcolorNotSelected;
  192. }
  193. }
  194. function HighLightTR2(el){
  195. if (document.myform.s2.checked == true) {
  196. el.bgColor=bgcolorSelected;
  197. } else {
  198. el.bgColor=bgcolorNotSelected;
  199. }
  200. }
  201. function HighLightTR3(el){
  202. if (document.myform.s3.checked == true) {
  203. el.bgColor=bgcolorSelected;
  204. } else {
  205. el.bgColor=bgcolorNotSelected;
  206. }
  207. }
  208. function HighLightTR4(el){
  209. if (document.myform.s4.checked == true) {
  210. el.bgColor=bgcolorSelected;
  211. } else {
  212. el.bgColor=bgcolorNotSelected;
  213. }
  214. }
  215.  
  216. function HighLightTR5(el){
  217. if (document.myform.s5.checked == true) {
  218. el.bgColor=bgcolorSelected;
  219. } else {
  220. el.bgColor=bgcolorNotSelected;
  221. }
  222. }
  223.  
  224. function HighLightTR6(el){
  225. if (document.myform.s6.checked == true) {
  226. el.bgColor=bgcolorSelected;
  227. } else {
  228. el.bgColor=bgcolorNotSelected;
  229. }
  230. }
  231.  
  232. function HighLightTR7(el){
  233. if (document.myform.s7.checked == true) {
  234. el.bgColor=bgcolorSelected;
  235. } else {
  236. el.bgColor=bgcolorNotSelected;
  237. }
  238. }
  239.  
  240. function HighLightTR8(el){
  241. if (document.myform.s8.checked == true) {
  242. el.bgColor=bgcolorSelected;
  243. } else {
  244. el.bgColor=bgcolorNotSelected;
  245. }
  246. }
  247.  
  248. function HighLightTR9(el){
  249. if (document.myform.s9.checked == true) {
  250. el.bgColor=bgcolorSelected;
  251. } else {
  252. el.bgColor=bgcolorNotSelected;
  253. }
  254. }
  255.  
  256. function HighLightTR10(el){
  257. if (document.myform.s10.checked == true) {
  258. el.bgColor=bgcolorSelected;
  259. } else {
  260. el.bgColor=bgcolorNotSelected;
  261. }
  262. }
  263.  
  264. function HighLightTR11(el){
  265. if (document.myform.s11.checked == true) {
  266. el.bgColor=bgcolorSelected;
  267. } else {
  268. el.bgColor=bgcolorNotSelected;
  269. }
  270. }
  271.  
  272. function HighLightTR12(el){
  273. if (document.myform.s12.checked == true) {
  274. el.bgColor=bgcolorSelected;
  275. } else {
  276. el.bgColor=bgcolorNotSelected;
  277. }
  278. }
  279.  
  280. function HighLightTR13(el){
  281. if (document.myform.s13.checked == true) {
  282. el.bgColor=bgcolorSelected;
  283. } else {
  284. el.bgColor=bgcolorNotSelected;
  285. }
  286. }
  287.  
  288. function HighLightTR14(el){
  289. if (document.myform.s14.checked == true) {
  290. el.bgColor=bgcolorSelected;
  291. } else {
  292. el.bgColor=bgcolorNotSelected;
  293. }
  294. }
  295.  
  296. function HighLightTR15(el){
  297. if (document.myform.s15.checked == true) {
  298. el.bgColor=bgcolorSelected;
  299. } else {
  300. el.bgColor=bgcolorNotSelected;
  301. }
  302. }
  303.  
  304. function HighLightTR16(el){
  305. if (document.myform.s16.checked == true) {
  306. el.bgColor=bgcolorSelected;
  307. } else {
  308. el.bgColor=bgcolorNotSelected;
  309. }
  310. }
  311.  
  312. function HighLightTR17(el){
  313. if (document.myform.s17.checked == true) {
  314. el.bgColor=bgcolorSelected;
  315. } else {
  316. el.bgColor=bgcolorNotSelected;
  317. }
  318. }
  319.  
  320. function HighLightTR18(el){
  321. if (document.myform.s18.checked == true) {
  322. el.bgColor=bgcolorSelected;
  323. } else {
  324. el.bgColor=bgcolorNotSelected;
  325. }
  326. }
  327.  
  328. function HighLightTR19(el){
  329. if (document.myform.s19.checked == true) {
  330. el.bgColor=bgcolorSelected;
  331. } else {
  332. el.bgColor=bgcolorNotSelected;
  333. }
  334. }
  335.  
  336. function HighLightTR20(el){
  337. if (document.myform.s20.checked == true) {
  338. el.bgColor=bgcolorSelected;
  339. } else {
  340. el.bgColor=bgcolorNotSelected;
  341. }
  342. }
  343.  
  344. function HighLightTR21(el){
  345. if (document.myform.s21.checked == true) {
  346. el.bgColor=bgcolorSelected;
  347. } else {
  348. el.bgColor=bgcolorNotSelected;
  349. }
  350. }
  351.  
  352. function HighLightTR22(el){
  353. if (document.myform.s22.checked == true) {
  354. el.bgColor=bgcolorSelected;
  355. } else {
  356. el.bgColor=bgcolorNotSelected;
  357. }
  358. }
  359.  
  360. function HighLightTR23(el){
  361. if (document.myform.s23.checked == true) {
  362. el.bgColor=bgcolorSelected;
  363. } else {
  364. el.bgColor=bgcolorNotSelected;
  365. }
  366. }
  367.  
  368. function HighLightTR24(el){
  369. if (document.myform.s24.checked == true) {
  370. el.bgColor=bgcolorSelected;
  371. } else {
  372. el.bgColor=bgcolorNotSelected;
  373. }
  374. }
  375.  
  376. function HighLightTR25(el){
  377. if (document.myform.s25.checked == true) {
  378. el.bgColor=bgcolorSelected;
  379. } else {
  380. el.bgColor=bgcolorNotSelected;
  381. }
  382. }
  383.  
  384. function HighLightTR26(el){
  385. if (document.myform.s26.checked == true) {
  386. el.bgColor=bgcolorSelected;
  387. } else {
  388. el.bgColor=bgcolorNotSelected;
  389. }
  390. }
  391.  
  392. function HighLightTR27(el){
  393. if (document.myform.s27.checked == true) {
  394. el.bgColor=bgcolorSelected;
  395. } else {
  396. el.bgColor=bgcolorNotSelected;
  397. }
  398. }
  399.  
  400. function HighLightTR28(el){
  401. if (document.myform.s28.checked == true) {
  402. el.bgColor=bgcolorSelected;
  403. } else {
  404. el.bgColor=bgcolorNotSelected;
  405. }
  406. }
  407.  
  408. function HighLightTR29(el){
  409. if (document.myform.s29.checked == true) {
  410. el.bgColor=bgcolorSelected;
  411. } else {
  412. el.bgColor=bgcolorNotSelected;
  413. }
  414. }
  415.  
  416. function HighLightTR30(el){
  417. if (document.myform.s30.checked == true) {
  418. el.bgColor=bgcolorSelected;
  419. } else {
  420. el.bgColor=bgcolorNotSelected;
  421. }
  422. }
  423.  
  424. function HighLightTR31(el){
  425. if (document.myform.s31.checked == true) {
  426. el.bgColor=bgcolorSelected;
  427. } else {
  428. el.bgColor=bgcolorNotSelected;
  429. }
  430. }
  431.  
  432. function HighLightTR32(el){
  433. if (document.myform.s32.checked == true) {
  434. el.bgColor=bgcolorSelected;
  435. } else {
  436. el.bgColor=bgcolorNotSelected;
  437. }
  438. }
  439.  
  440. function HighLightTR33(el){
  441. if (document.myform.s33.checked == true) {
  442. el.bgColor=bgcolorSelected;
  443. } else {
  444. el.bgColor=bgcolorNotSelected;
  445. }
  446. }
  447.  
  448. function HighLightTR34(el){
  449. if (document.myform.s34.checked == true) {
  450. el.bgColor=bgcolorSelected;
  451. } else {
  452. el.bgColor=bgcolorNotSelected;
  453. }
  454. }
  455.  
  456. function HighLightTR35(el){
  457. if (document.myform.s35.checked == true) {
  458. el.bgColor=bgcolorSelected;
  459. } else {
  460. el.bgColor=bgcolorNotSelected;
  461. }
  462. }
  463.  
  464. function HighLightTR36(el){
  465. if (document.myform.s36.checked == true) {
  466. el.bgColor=bgcolorSelected;
  467. } else {
  468. el.bgColor=bgcolorNotSelected;
  469. }
  470. }
  471.  
  472. function HighLightTR37(el){
  473. if (document.myform.s37.checked == true) {
  474. el.bgColor=bgcolorSelected;
  475. } else {
  476. el.bgColor=bgcolorNotSelected;
  477. }
  478. }
  479.  
  480. function HighLightTR38(el){
  481. if (document.myform.s38.checked == true) {
  482. el.bgColor=bgcolorSelected;
  483. } else {
  484. el.bgColor=bgcolorNotSelected;
  485. }
  486. }
  487.  
  488. function HighLightTR39(el){
  489. if (document.myform.s39.checked == true) {
  490. el.bgColor=bgcolorSelected;
  491. } else {
  492. el.bgColor=bgcolorNotSelected;
  493. }
  494. }
  495.  
  496. </script>
  497. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  498. <title>BuckleUp Online Reservation</title>
  499. </head>
  500. <link href="style.css" rel="stylesheet" type="text/css" media="screen">
  501. <body>
  502. <div id="wrapper">
  503. <div id="header">
  504. <div id="menu">
  505. <ul>
  506. <li class="current_page_item"><a href="index.html">Home</a></li>
  507. <li><a href="penafrancia.htm">Peñafrancia</a></li>
  508. <li><a href="philtranco.htm">Philtranco</a></li>
  509. <li><a href="silverstar.htm">Silver Star</a></li>
  510. <li><a href="cancellation.htm">Cancellation</a></li>
  511. <li><a href="faqs.htm">FAQS</a></li>
  512. </ul>
  513. </div>
  514. <!-- end #menu -->
  515.  
  516. </div>
  517. <div id="logo">
  518. <center><img border="0" src="images/buckleup.jpg" width="800" height="300"></center>
  519. </div>
  520. <div id="page">
  521. ___________________________________________________________________________________________________________________
  522. <br><br><br>
  523.  
  524.  
  525.  
  526. <?php
  527. //include_once('header.php');
  528. //include_once('menu.php');
  529. ?>
  530.  
  531. <?php
  532. if ($_REQUEST['status'] == 1) {
  533. echo "<p>Youre reservation is done, please pay at the office.</p>";
  534. }
  535. ?>
  536.  
  537.  
  538. <?php if ($_REQUEST['ShowSeat']!='1') { ?>
  539.  
  540.  
  541. <form name="search" action="" method="POST">
  542. <center>
  543. <b><font color="#FFFFFF">From</font> </b>
  544. <?php echo $DepartureList ?><br><br>
  545. <b><font color="#FFFFFF">To</font></b>&nbsp;&nbsp;&nbsp;&nbsp;
  546. <?php echo $DestinationList ?><br><br>
  547. <b><font color="#FFFFFF">Date</font> </b>
  548. <input type="text" size="12" id="inputField" name="DepartureDate" value="<?php echo $_POST['DepartureDate']; ?>">
  549. <!-- <input type="text" name="DepartureDate" value="<?php echo $_POST['DepartureDate']; ?>">-->
  550.  
  551. <br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  552.  
  553. <input type="submit" name="Search" value="search"><br>
  554. __________________________________________________
  555. </center>
  556.  
  557.  
  558. <?php if ($result != '') { ?>
  559. <?php echo $result; ?>
  560. <input type="submit" name="reserve" value="reserve">
  561. <?php } ?>
  562.  
  563. <?php } ?>
  564. </form>
  565.  
  566. </li>
  567. </ul>
  568. </div>
  569. </div>
  570.  
  571.  
  572.  
  573. <?php if ($_REQUEST['ShowSeat']=='1')
  574. {
  575.  
  576. $database->Connect();
  577. $sql = "SELECT * FROM departure WHERE DepartureID = {$_REQUEST['DepartureID']}";
  578. $rs = $database->executeQuery($sql);
  579. $row = mysql_fetch_array($rs);
  580.  
  581. echo "
  582.  
  583. <font color=\"#FFFF00\"><b>
  584.  
  585. FROM: </font></b> <font color=\"#FFFFFF\">{$row['DepartureName']}</font>";
  586.  
  587. $sql = "SELECT * FROM departure WHERE DepartureID = {$_REQUEST['DepartureID']}";
  588. $rs = $database->executeQuery($sql);
  589. $row = mysql_fetch_array($rs);
  590.  
  591. $sql = "SELECT * FROM destination WHERE DestinationID = {$_REQUEST['DestinationID']}";
  592. $rs = $database->executeQuery($sql);
  593. $row = mysql_fetch_array($rs);
  594.  
  595. echo "<br>
  596.  
  597. <font color=\"#FFFF00\"><b>
  598.  
  599. TO: </font></b> <font color=\"#FFFFFF\">{$row['DestinationName']}</font>";
  600.  
  601. $sql = "SELECT * FROM route WHERE RouteID = {$_REQUEST['RouteID']}";
  602. $rs = $database->executeQuery($sql);
  603. $row = mysql_fetch_array($rs);
  604.  
  605. echo "<br>
  606. <font color=\"#FFFF00\"><b>
  607.  
  608. DEPARTURE DATE: </font></b> <font color=\"#FFFFFF\">{$_REQUEST['DepartureDate']}</font>" .
  609.  
  610. "<br>
  611. <font color=\"#FFFF00\"><b>
  612.  
  613. DEPARTURE TIME: </font></b> <font color=\"#FFFFFF\">{$row['TimeDest']}</font>" .
  614.  
  615. "<br>
  616. <font color=\"#FFFF00\"><b>
  617.  
  618. ETA: </font></b> <font color=\"#FFFFFF\">{$row['TimeADest']}</font>" .
  619.  
  620. "<br>
  621. <font color=\"#FFFF00\"><b>
  622.  
  623. AMOUNT (PESO) : </font></b> <font color=\"#FFFFFF\">{$row['Amount']}</font>";
  624.  
  625. $database->Disconnect();
  626. ?>
  627. <form name="myform" action="" method="POST">
  628. <div align="center">
  629. <br><br>
  630. <table border="1" style="font-size:10px;" width="300">
  631. <td height="50" width="50"><font color="red">Back</font></td>
  632. </table>
  633. <table border="1" style="font-size:10px;" width="300">
  634.  
  635. <tr align="center">
  636. <td height="50" width="50"><font color="#FFFFFF">Co-Driver's Seat</font></td>
  637. <td height="50" width="50" onClick="HighLightTR39(this);" <?php echo $c[39];?>><input type="checkbox" name="s39" value="39" <?php echo $s[39]; ?>><br><font color="#FFFFFF">39</font></td>
  638. <td height="50" width="50" onClick="HighLightTR38(this);" <?php echo $c[38];?>><input type="checkbox" name="s38" value="38" <?php echo $s[38]; ?>><br><font color="#FFFFFF">38</font></td>
  639. <td height="50" width="50" onClick="HighLightTR37(this);" <?php echo $c[37];?>><input type="checkbox" name="s37" value="37" <?php echo $s[37]; ?>><br><font color="#FFFFFF">37</font></td>
  640. </tr>
  641. </table>
  642. <table border="1" style="font-size:10px;" width="300">
  643. <tr align="center">
  644. <td height="50" width="50" onClick="HighLightTR36(this);" <?php echo $c[36];?>><input type="checkbox" name="s36" value="36" <?php echo $s[36]; ?>><br><font color="#FFFFFF">36</font></td>
  645. <td height="50" width="50" onClick="HighLightTR35(this);" <?php echo $c[35];?>><input type="checkbox" name="s35" value="35" <?php echo $s[35]; ?>><br><font color="#FFFFFF">35</font></td>
  646. <td height="50" width="100">&nbsp;</td>
  647. <td height="50" width="50" onClick="HighLightTR34(this);" <?php echo $c[34];?>><input type="checkbox" name="s34" value="34" <?php echo $s[34]; ?>><br><font color="#FFFFFF">34</font></td>
  648. <td height="50" width="50" onClick="HighLightTR33(this);" <?php echo $c[33];?>><input type="checkbox" name="s33" value="33" <?php echo $s[33]; ?>><br><font color="#FFFFFF">33</font></td>
  649. </tr>
  650. <tr align="center">
  651. <td height="50" width="50" onClick="HighLightTR32(this);" <?php echo $c[32];?>><input type="checkbox" name="s32" value="32" <?php echo $s[32]; ?>><br><font color="#FFFFFF">32</font></td>
  652. <td height="50" width="50" onClick="HighLightTR31(this);" <?php echo $c[31];?>><input type="checkbox" name="s31" value="31" <?php echo $s[31]; ?>><br><font color="#FFFFFF">31</font></td>
  653. <td height="50" width="100">&nbsp;</td>
  654. <td height="50" width="50" onClick="HighLightTR30(this);" <?php echo $c[30];?>><input type="checkbox" name="s30" value="30" <?php echo $s[30]; ?>><br><font color="#FFFFFF">30</font></td>
  655. <td height="50" width="50" onClick="HighLightTR29(this);" <?php echo $c[29];?>><input type="checkbox" name="s29" value="29" <?php echo $s[29]; ?>><br><font color="#FFFFFF">29</font></td>
  656. </tr>
  657. <tr align="center">
  658. <td height="50" width="50" onClick="HighLightTR28(this);" <?php echo $c[28];?>><input type="checkbox" name="s28" value="28" <?php echo $s[28]; ?>><br><font color="#FFFFFF">28</font></td>
  659. <td height="50" width="50" onClick="HighLightTR27(this);" <?php echo $c[27];?>><input type="checkbox" name="s27" value="27" <?php echo $s[27]; ?>><br><font color="#FFFFFF">27</font></td>
  660. <td height="50" width="100">&nbsp;</td>
  661. <td height="50" width="50" onClick="HighLightTR26(this);" <?php echo $c[26];?>><input type="checkbox" name="s26" value="26" <?php echo $s[26]; ?>><br><font color="#FFFFFF">26</font></td>
  662. <td height="50" width="50" onClick="HighLightTR25(this);" <?php echo $c[25];?>><input type="checkbox" name="s25" value="25" <?php echo $s[25]; ?>><br><font color="#FFFFFF">25</font></td>
  663. </tr>
  664. <tr align="center">
  665. <td height="50" width="50" onClick="HighLightTR24(this);" <?php echo $c[24];?>><input type="checkbox" name="s24" value="24" <?php echo $s[24]; ?>><br><font color="#FFFFFF">24</font></td>
  666. <td height="50" width="50" onClick="HighLightTR23(this);" <?php echo $c[23];?>><input type="checkbox" name="s23" value="23" <?php echo $s[23]; ?>><br><font color="#FFFFFF">23</font></td>
  667. <td height="50" width="100">&nbsp;</td>
  668. <td height="50" width="50" onClick="HighLightTR22(this);" <?php echo $c[22];?>><input type="checkbox" name="s22" value="22" <?php echo $s[22]; ?>><br><font color="#FFFFFF">22</font></td>
  669. <td height="50" width="50" onClick="HighLightTR21(this);" <?php echo $c[21];?>><input type="checkbox" name="s21" value="21" <?php echo $s[21]; ?>><br><font color="#FFFFFF">21</font></td>
  670. </tr>
  671. <tr align="center">
  672. <td height="50" width="50" onClick="HighLightTR20(this);" <?php echo $c[20];?>><input type="checkbox" name="s20" value="20" <?php echo $s[20]; ?>><br><font color="#FFFFFF">20</font></td>
  673. <td height="50" width="50" onClick="HighLightTR19(this);" <?php echo $c[19];?>><input type="checkbox" name="s19" value="19" <?php echo $s[19]; ?>><br><font color="#FFFFFF">19</font></td>
  674. <td height="50" width="100">&nbsp;</td>
  675. <td height="50" width="50" onClick="HighLightTR18(this);" <?php echo $c[18];?>><input type="checkbox" name="s18" value="18" <?php echo $s[18]; ?>><br><font color="#FFFFFF">18</font></td>
  676. <td height="50" width="50" onClick="HighLightTR17(this);" <?php echo $c[17];?>><input type="checkbox" name="s17" value="17" <?php echo $s[17]; ?>><br><font color="#FFFFFF">17</font></td>
  677. </tr>
  678. <tr align="center">
  679. <td height="50" width="50" onClick="HighLightTR16(this);" <?php echo $c[16];?>><input type="checkbox" name="s16" value="16" <?php echo $s[16]; ?>><br><font color="#FFFFFF">16</font></td>
  680. <td height="50" width="50" onClick="HighLightTR15(this);" <?php echo $c[15];?>><input type="checkbox" name="s15" value="15" <?php echo $s[15]; ?>><br><font color="#FFFFFF">15</font></td>
  681. <td height="50" width="100">&nbsp;</td>
  682. <td height="50" width="50" onClick="HighLightTR14(this);" <?php echo $c[14];?>><input type="checkbox" name="s14" value="14" <?php echo $s[14]; ?>><br><font color="#FFFFFF">14</font></td>
  683. <td height="50" width="50" onClick="HighLightTR13(this);" <?php echo $c[13];?>><input type="checkbox" name="s13" value="13" <?php echo $s[13]; ?>><br><font color="#FFFFFF">13</font></td>
  684. </tr>
  685. <tr align="center">
  686. <td height="50" width="50" onClick="HighLightTR12(this);" <?php echo $c[12];?>><input type="checkbox" name="s12" value="12" <?php echo $s[12]; ?>><br><font color="#FFFFFF">12</font></td>
  687. <td height="50" width="50" onClick="HighLightTR11(this);" <?php echo $c[11];?>><input type="checkbox" name="s11" value="11" <?php echo $s[11]; ?>><br><font color="#FFFFFF">11</font></td>
  688. <td height="50" width="100">&nbsp;</td>
  689. <td height="50" width="50" onClick="HighLightTR10(this);" <?php echo $c[10];?>><input type="checkbox" name="s10" value="10" <?php echo $s[10]; ?>><br><font color="#FFFFFF">10</font></td>
  690. <td height="50" width="50" onClick="HighLightTR9(this);" <?php echo $c[9];?>><input type="checkbox" name="s9" value="9" <?php echo $s[9]; ?>><br><font color="#FFFFFF">09</font></td>
  691. </tr>
  692. <tr align="center">
  693. <td height="50" width="50" onClick="HighLightTR8(this);" <?php echo $c[8];?>><input type="checkbox" name="s8" value="8" <?php echo $s[8]; ?>><br><font color="#FFFFFF">08</font></td>
  694. <td height="50" width="50" onClick="HighLightTR7(this);" <?php echo $c[7];?>><input type="checkbox" name="s7" value="7" <?php echo $s[7]; ?>><br><font color="#FFFFFF">07</font></td>
  695. <td height="50" width="100">&nbsp;</td>
  696. <td height="50" width="50" onClick="HighLightTR6(this);" <?php echo $c[6];?>><input type="checkbox" name="s6" value="6" <?php echo $s[6]; ?>><br><font color="#FFFFFF">06</font></td>
  697. <td height="50" width="50" onClick="HighLightTR5(this);" <?php echo $c[5];?>><input type="checkbox" name="s5" value="5" <?php echo $s[5]; ?>><br><font color="#FFFFFF">05</font></td>
  698. </tr>
  699. <tr align="center">
  700. <td height="50" width="50" onClick="HighLightTR4(this);" <?php echo $c[4];?>><input type="checkbox" name="s4" value="4" <?php echo $s[4]; ?>><br><font color="#FFFFFF">04</font></td>
  701. <td height="50" width="50" onClick="HighLightTR3(this);" <?php echo $c[3];?>><input type="checkbox" name="s3" value="3" <?php echo $s[3]; ?>><br><font color="#FFFFFF">03</font></td>
  702. <td height="50" width="100">&nbsp;</td>
  703. <td height="50" width="50" onClick="HighLightTR2(this);" <?php echo $c[2];?>><input type="checkbox" name="s2" value="2" <?php echo $s[2]; ?>><br><font color="#FFFFFF">02</font></td>
  704. <td height="50" width="50" onClick="HighLightTR1(this);" <?php echo $c[1];?>><input type="checkbox" name="s1" value="1" <?php echo $s[1]; ?>><br><font color="#FFFFFF">01</font></td>
  705. </tr>
  706. <tr align="center">
  707. <td height="50" width="50" colspan="4">&nbsp;</td>
  708. <td height="50" width="50"><font color="#FFFFFF">Driver</font></td>
  709. </tr>
  710.  
  711. </table>
  712. <table border="1" style="font-size:10px;" width="300">
  713. <td height="50" width="50"><font color="red">Front</font></td>
  714. </table>
  715.  
  716. </div>
  717. <br><br>
  718. <center><input type="submit" name="submit" value="Reserve">
  719. <input type="submit" name="cancel" value="Cancel"></center>
  720. </form>
  721. <?php } ?>
  722.  
  723. </div>
  724.  
  725. </body>
  726. </html>
  727.  
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,075
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: count checkboxes

 
0
  #2
Sep 25th, 2009
Could you please post just the relevant bit of code. It is very hard to wade through 10 page lengths of code.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 55
Reputation: wilch is an unknown quantity at this point 
Solved Threads: 9
wilch wilch is offline Offline
Junior Poster in Training

Re: count checkboxes

 
0
  #3
Sep 25th, 2009
To optimise your code for readablity, and avoiding boredom of scrolling down - like i experienced. Replace your js functions such as
  1. function HighLightTR39(el, rowName){
  2. if (document.myform.s39.checked == true) {
  3. el.bgColor=bgcolorSelected;
  4. } else {
  5. el.bgColor=bgcolorNotSelected;
  6. }
  7. }

using one function similar to the one below which passes the changing field s1, s2 ... sn, as a variable sName. This or something similar will eliminate exactly 300 lines of code.
  1. function HighLightTR(el, sName){
  2. if (document.myform.sName.checked == true) {
  3. el.bgColor=bgcolorSelected;
  4. } else {
  5. el.bgColor=bgcolorNotSelected;
  6. }
  7. }
umm.. by the way how do you do it ?
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,075
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: count checkboxes

 
0
  #4
Sep 25th, 2009
Originally Posted by wilch View Post
To optimise your code for readablity, and avoiding boredom of scrolling down - like i experienced. Replace your js functions such as
  1. function HighLightTR39(el, rowName){
  2. if (document.myform.s39.checked == true) {
  3. el.bgColor=bgcolorSelected;
  4. } else {
  5. el.bgColor=bgcolorNotSelected;
  6. }
  7. }

using one function similar to the one below which passes the changing field s1, s2 ... sn, as a variable sName. This or something similar will eliminate exactly 300 lines of code.
  1. function HighLightTR(el, sName){
  2. if (document.myform.sName.checked == true) {
  3. el.bgColor=bgcolorSelected;
  4. } else {
  5. el.bgColor=bgcolorNotSelected;
  6. }
  7. }
Probably need:

  1. function HighLightTR(el, sName){
  2. if (document.myform[sName].checked == true) {
  3. el.bgColor=bgcolorSelected;
  4. } else {
  5. el.bgColor=bgcolorNotSelected;
  6. }
  7. }

document.myform.sName.checked would treat sName as the literal string "sName".
IE:
  1. document.myform['sName'].checked

but you want:

  1. document.myform[sName].checked

where it is the property name.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC