Customized Mathematical calculations by building simple functions and make use of them on event changes


/ Published in: JavaScript
Save to your folder(s)

I have developed this applications based on my requirement for the projects you can change accordingly, as per you r specifications....


if anyone has any doubt please post it will send explanation for it


Copy this code and paste it in your HTML
  1. <!--By shashi-->
  2. <script language="javascript" src="valid.js"></script>
  3. <!--add into head part-->
  4.  
  5. <body onLoad="e1(),calc1(),ov_sc(),avgcalc1(),avgtot(),crosscons(),totagg()"> <!--make sure on load does exist to fire deafult values-->
  6. <form name="ehsauditchklist" id="ehsauditchklist" action="?mode=ehsauditchklist" method="post" onSubmit="return check2();">
  7. <input type="hidden" name="flag" value="">
  8.  
  9.  
  10. <br/>
  11.  
  12. <h4 align="center">Check List Selection </h4>
  13. <table class="" align="center" width="91%" border="0">
  14. <tr>
  15. <td>&nbsp;</td>
  16. </tr>
  17. </table>
  18.  
  19. <table class="bord" align="center" width="91%" border="1">
  20.  
  21. <tr>
  22. <th colspan="6" align="left"></th>
  23. </tr>
  24.  
  25. <tr>
  26. <td align="right" colspan="6"><b></b></td>
  27. </tr>
  28.  
  29.  
  30.  
  31.  
  32.  
  33. <form name="ehs_form" id="ehs_form" action="" method="post" enctype="multipart/form-data">
  34.  
  35. <input type="hidden" name="plant_id" value="{$output_for_vill_plant[0][1]}"><!--get your values what ever needed for headings from the controller page and throw them to front end-->
  36.  
  37.  
  38. <table width="94%" align="center" border="0" >
  39. <tr>
  40.  
  41. <td width="35%" align="left" ><img src="images/whlogo.gif" style="border:none" /></td>
  42. <td width="65%" align="left" valign="middle"><h2 align="left">EHS Audit Checklist Entry</h2></td>
  43. </tr>
  44. </table>
  45. <br/>
  46.  
  47. <table width="78%" class="" align="center" border="0" style="border-top:none" bgcolor="#EBEBEB">
  48.  
  49. <tr >
  50. <td width="14%" height="" align="right"><div align="left"><strong>WHC Name</strong></div></td>
  51. <td width="32%">:
  52. <span id="plant_name_div">
  53. <input type="text" name="who_name" id="whc_name" value="{$output_for_vill_plant[0][0]}" readonly /></span></td>
  54.  
  55.  
  56. <td width="26%" height=""align="right"><div align="left"><strong>Operator Name</strong></div></td>
  57.  
  58. <td width="28%" height="">: <span id="mandal_name_div">
  59. <input type="text" name="oper_name" id="oper_name" /></span></td>
  60. </tr>
  61.  
  62. <tr >
  63.  
  64. <td height=""align="right"><div align="left"><strong>Date</strong></div></td>
  65.  
  66. <td height="">: <span id="mandal_name_div"><input type="text" name="from_dts1" readonly id="from_dts1" size="" value="">&nbsp;<img src="images/cal.gif" border="0" valign="center" title='Click Here' alt='Click Here' onClick="scwShow(document.getElementById('from_dts1'),this);" /></span></td>
  67.  
  68.  
  69. <td height=""align="right"><div align="left"><strong>Quality Executive Name</strong></div></td>
  70.  
  71. <td height="">: <span id="mandal_name_div"><input type="text" name="qua_ex_nam" id="qua_ex_nam" /></span></td>
  72. </tr>
  73. </table>
  74.  
  75. <bR />
  76.  
  77. <table width="95%" class="bord" align="center" border="0" style="" frame="box" rules="none" cellpadding="0" cellspacing="0" bgcolor="">
  78. <tr>
  79. <th width="4%">S.No</th>
  80. <th width="50%" align="center">&nbsp;Parameter</th>
  81. <th width="7%">Impact</th>
  82. <th width="9%">Applicability</th>
  83. <th width="5%">Score</th>
  84. <th width="7%">Weighted Score</th>
  85. <th width="9%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Remarks</th>
  86. </tr>
  87. <tr>
  88. <td bgcolor="#EBEBEB">&nbsp;</td>
  89. <td colspan="9" align="left" bgcolor="#EBEBEB">ENVIRONMENTAL AND SOCIAL</td>
  90. </tr>
  91. <tr>
  92. <td width="4%">1.</td>
  93. <td width="50%">Clause1</td>
  94. <td width="7%">CR</td>
  95. <td width="9%"><select name="y_n_1" onChange="c1()">{html_options options=$y_n_arr}</select></td><!--same get the valeus from controller in your language repeat for the rest-->
  96. <td width="5%"><select name="sco_1" onChange="d1()">{html_options options=$dec_point}</select></td>
  97. <td width="7%">
  98. <input type="text" name="wei_sco1" id="wei_sco1" value="" size="4" maxlength="4" onFocus="e1()" readonly />
  99. </td>
  100. <td width="9%"><textarea name="rem_1" id="rem_1" cols="25" rows="2"></textarea></td>
  101. </tr>
  102. <tr>
  103. <td>2.</td>
  104. <td>Clause2</td>
  105. <td>CR</td>
  106. <td><select name="y_n_2" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  107. <td><select name="sco_2" onChange="d1()">{html_options options=$dec_point}</select></td>
  108. <td><input type="text" name="wei_sco2" id="wei_sco2" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  109. <td><textarea name="rem_2" id="rem_2" cols="25" rows="2"></textarea></td>
  110. </tr>
  111. <tr>
  112. <td>3.</td>
  113. <td>Clause3</td>
  114. <td>MA</td>
  115. <td><select name="y_n_3" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  116. <td><select name="sco_3" onChange="d1()">{html_options options=$dec_point}</select></td>
  117. <td><input type="text" name="wei_sco3" id="wei_sco3" value="" size="4" maxlength="4" onChange="e1()" readonly /></td>
  118. <td><textarea name="rem_3" id="rem_3" cols="25" rows="2"></textarea></td>
  119. </tr>
  120. <tr>
  121. <td>4.</td>
  122. <td>Clause4</td>
  123. <td>MI</td>
  124. <td><select name="y_n_4" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  125. <td><select name="sco_4" onChange="d1()">{html_options options=$dec_point}</select></td>
  126. <td><input type="text" name="wei_sco4" id="wei_sco4" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  127. <td><textarea name="rem_4" id="rem_4" cols="25" rows="2"></textarea></td>
  128. </tr>
  129. <tr>
  130. <td>5.</td>
  131. <td>Clause5</td>
  132. <td>MI</td>
  133. <td><select name="y_n_5" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  134. <td><select name="sco_5" onChange="d1()">{html_options options=$dec_point}</select></td>
  135. <td><input type="text" name="wei_sco5" id="wei_sco5" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  136. <td><textarea name="rem_5" id="rem_5" cols="25" rows="2"></textarea></td>
  137. </tr>
  138. <tr>
  139. <td bgcolor="#EBEBEB">&nbsp;</td>
  140. <td colspan="9" align="left" bgcolor="#EBEBEB">HEALTH AND SAFETY</td>
  141. </tr>
  142. <tr>
  143. <td width="4%">6.</td>
  144. <td width="50%">Clause6</td>
  145. <td width="7%">CR</td>
  146. <td width="9%"><select name="y_n_6" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  147. <td width="5%"><select name="sco_6" onChange="d1()">{html_options options=$dec_point}</select></td>
  148. <td width="7%">
  149. <input type="text" name="wei_sco6" id="wei_sco6" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  150. <td width="9%"><textarea name="rem_6" id="rem_6" cols="25" rows="2"></textarea></td>
  151. </tr>
  152. <tr>
  153. <td>7.</td>
  154. <td>Clause7</td>
  155. <td>CR</td>
  156. <td><select name="y_n_7" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  157. <td><select name="sco_7" onChange="d1()">{html_options options=$dec_point}</select></td>
  158. <td><input type="text" name="wei_sco7" id="wei_sco7" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  159. <td><textarea name="rem_7" id="rem_7" cols="25" rows="2"></textarea></td>
  160. </tr>
  161. <tr>
  162. <td>8.</td>
  163. <td>Clause8</td>
  164. <td>CR</td>
  165. <td><select name="y_n_8" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  166. <td><select name="sco_8" onChange="d1()">{html_options options=$dec_point}</select></td>
  167. <td><input type="text" name="wei_sco8" id="wei_sco8" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  168. <td><textarea name="rem_8" id="rem_9" cols="25" rows="2"></textarea></td>
  169. </tr>
  170. <tr>
  171. <td>9.</td>
  172. <td>Clause9</td>
  173. <td>CR</td>
  174. <td><select name="y_n_9" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  175. <td><select name="sco_9" onChange="d1()">{html_options options=$dec_point}</select></td>
  176. <td><input type="text" name="wei_sco9" id="wei_sco9" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  177. <td><textarea name="rem_9" id="rem_9" cols="25" rows="2"></textarea></td>
  178. </tr>
  179. <tr>
  180. <td>10.</td>
  181. <td>Clause10</td>
  182. <td>MA</td>
  183. <td><select name="y_n_10" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  184. <td><select name="sco_10" onChange="d1()">{html_options options=$dec_point}</select></td>
  185. <td><input type="text" name="wei_sco10" id="wei_sco10" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  186. <td><textarea name="rem_10" id="rem_10" cols="25" rows="2"></textarea></td>
  187. </tr>
  188. <tr>
  189. <td>11.</td>
  190. <td>Clause11</td>
  191. <td>MA</td>
  192. <td><select name="y_n_11" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  193. <td><select name="sco_11" onChange="d1()">{html_options options=$dec_point}</select></td>
  194. <td><input type="text" name="wei_sco11" id="wei_sco11" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  195. <td><textarea name="rem_11" id="textarea11" cols="25" rows="2"></textarea></td>
  196. </tr>
  197. <tr>
  198. <td>12.</td>
  199. <td>Clause12</td>
  200. <td>MA</td>
  201. <td><select name="y_n_12" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  202. <td><select name="sco_12" onChange="d1()">{html_options options=$dec_point}</select></td>
  203. <td><input type="text" name="wei_sco12" id="wei_sco12" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  204. <td><textarea name="rem_12" id="textarea11" cols="25" rows="2"></textarea></td>
  205. </tr>
  206. <tr>
  207. <td>13.</td>
  208. <td>Clause13</td>
  209. <td>MI</td>
  210. <td><select name="y_n_13" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  211. <td><select name="sco_13" onChange="d1()">{html_options options=$dec_point}</select></td>
  212. <td><input type="text" name="wei_sco13" id="wei_sco13" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  213. <td><textarea name="textarea12" id="textarea12" cols="25" rows="2"></textarea></td>
  214. </tr>
  215. <tr>
  216. <td>14.</td>
  217. <td>Clause14</td>
  218. <td>MI</td>
  219. <td><select name="y_n_14" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  220. <td><select name="sco_14" onChange="d1()">{html_options options=$dec_point}</select></td>
  221. <td><input type="text" name="wei_sco14" id="wei_sco14" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  222. <td><textarea name="textarea13" id="textarea13" cols="25" rows="2"></textarea></td>
  223. </tr>
  224. <tr>
  225. <td bgcolor="#EBEBEB">&nbsp;</td>
  226. <td colspan="9" align="left" bgcolor="#EBEBEB">HOUSEKEEPING</td>
  227. </tr>
  228. <tr>
  229. <td>15.</td>
  230. <td>Clause15</td>
  231. <td>CR</td>
  232. <td><select name="y_n_15" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  233. <td><select name="sco_15" onChange="d1()">{html_options options=$dec_point}</select></td>
  234. <td><input type="text" name="wei_sco15" id="wei_sco15" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  235. <td><textarea name="textarea14" id="textarea14" cols="25" rows="2"></textarea></td>
  236. </tr>
  237. <tr>
  238. <td>16.</td>
  239. <td>Clause16</td>
  240. <td>CR</td>
  241. <td><select name="y_n_16" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  242. <td><select name="sco_16" onChange="d1()">{html_options options=$dec_point}</select></td>
  243. <td><input type="text" name="wei_sco16" id="wei_sco16" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  244. <td><textarea name="textarea15" id="textarea15" cols="25" rows="2"></textarea></td>
  245. </tr>
  246. <tr>
  247. <td>17.</td>
  248. <td>Clause17</td>
  249. <td>CR</td>
  250. <td><select name="y_n_17" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  251. <td><select name="sco_17" onChange="d1()">{html_options options=$dec_point}</select></td>
  252. <td><input type="text" name="wei_sco17" id="wei_sco17" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  253. <td><textarea name="textarea16" id="textarea16" cols="25" rows="2"></textarea></td>
  254. </tr>
  255. <tr>
  256. <td>18.</td>
  257. <td>Clause18</td>
  258. <td>MA</td>
  259. <td><select name="y_n_18" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  260. <td><select name="sco_18" onChange="d1()">{html_options options=$dec_point}</select></td>
  261. <td><input type="text" name="wei_sco18" id="wei_sco18" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  262. <td><textarea name="textarea17" id="textarea17" cols="25" rows="2"></textarea></td>
  263. </tr>
  264. <tr>
  265. <td>19.</td>
  266. <td>Clause19</td>
  267. <td>MA</td>
  268. <td><select name="y_n_19" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  269. <td><select name="sco_19" onChange="d1()">{html_options options=$dec_point}</select></td>
  270. <td><input type="text" name="wei_sco19" id="wei_sco19" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  271. <td><textarea name="textarea18" id="textarea18" cols="25" rows="2"></textarea></td>
  272. </tr>
  273.  
  274. <tr>
  275. <td bgcolor="#EBEBEB">&nbsp;</td>
  276. <td colspan="9" align="left" bgcolor="#EBEBEB">RECORDS AND DOCUMENTS</td>
  277. </tr>
  278. <tr>
  279. <td>20.</td>
  280. <td>Clause20</td>
  281. <td>CR</td>
  282. <td><select name="y_n_20" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  283. <td><select name="sco_20" onChange="d1()">{html_options options=$dec_point}</select></td>
  284. <td><input type="text" name="wei_sco20" id="wei_sco20" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  285. <td><textarea name="textarea19" id="textarea19" cols="25" rows="2"></textarea></td>
  286. </tr>
  287. <tr>
  288. <td>21.</td>
  289. <td>Clause21</td>
  290. <td>MI</td>
  291. <td><select name="y_n_21" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  292. <td><select name="sco_21" onChange="d1()">{html_options options=$dec_point}</select></td>
  293. <td><input type="text" name="wei_sco21" id="wei_sco21" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  294. <td><textarea name="textarea20" id="textarea20" cols="25" rows="2"></textarea></td>
  295. </tr>
  296. <tr>
  297. <td>22.</td>
  298. <td>Clause22</td>
  299. <td>MI</td>
  300. <td><select name="y_n_22" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  301. <td><select name="sco_22" onChange="d1()">{html_options options=$dec_point}</select></td>
  302. <td><input type="text" name="wei_sco22" id="wei_sco22" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  303. <td><textarea name="textarea21" id="textarea21" cols="25" rows="2"></textarea></td>
  304. </tr>
  305. <tr>
  306. <td>23.</td>
  307. <td>Clause23</td>
  308. <td>MI</td>
  309. <td><select name="y_n_23" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  310. <td><select name="sco_23" onChange="d1()">{html_options options=$dec_point}</select></td>
  311. <td><input type="text" name="wei_sco23" id="wei_sco23" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  312. <td><textarea name="textarea22" id="textarea22" cols="25" rows="2"></textarea></td>
  313. </tr>
  314. <tr>
  315. <td>24.</td>
  316. <td>Clause24</td>
  317. <td>MI</td>
  318. <td><select name="y_n_24" onChange="c1()">{html_options options=$y_n_arr}</select></td>
  319. <td><select name="sco_24" onChange="d1()">{html_options options=$dec_point}</select></td>
  320. <td><input type="text" name="wei_sco24" id="wei_sco24" value="" size="4" maxlength="4" onFocus="e1()" readonly /></td>
  321. <td><textarea name="textarea23" id="textarea23" cols="25" rows="2"></textarea></td>
  322. </tr>
  323. </table>
  324. <br />
  325.  
  326. <table width="65%" class="bord" align="center" border="0" style="" frame="box" rules="none" cellpadding="0" cellspacing="0" bgcolor="">
  327. <tr>
  328.  
  329. <th width="29%" align="center">Scoring Parameters in Percentages</th>
  330. <th width="23%">EHS Score</th>
  331. <th width="23%">Max Applicable Score</th>
  332. <th width="23%">Percentage</th>
  333. </tr>
  334. <tr>
  335. <td>Environmental Score</td>
  336. <td><input type="text" name="es_score" id="es_score" maxlength="4" readonly onFocus="calc1()" /></td>
  337. <td><input type="text" name="es_max_score" id="es_max_score" maxlength="4" readonly onFocus="avgcalc1()" /></td>
  338. <td><input type="text" name="es_percent" id="es_percent" maxlength="4" readonly onFocus="crosscons()" /></td>
  339. </tr>
  340. <tr>
  341. <td>Healthy and Safety Score</td>
  342. <td><input type="text" name="hss_score" id="hss_score" maxlength="4" readonly onFocus="calc1()" /></td>
  343. <td><input type="text" name="hss_max_score" id="hss_max_score" maxlength="4" readonly onFocus="avgcalc1()" /></td>
  344. <td><input type="text" name="hss_percent" id="hss_percent" maxlength="4" readonly onFocus="crosscons()" /></td>
  345. </tr>
  346. <tr>
  347. <td>Housekeeping Score</td>
  348. <td><input type="text" name="hk_score" id="hk_score" maxlength="4" readonly onFocus="calc1()" /></td>
  349. <td><input type="text" name="hk_max_score" id="hk_max_score" maxlength="4" readonly onFocus="avgcalc1()" /></td>
  350. <td><input type="text" name="hk_percent" id="hk_percent" maxlength="4" readonly onFocus="crosscons()" /></td>
  351. </tr>
  352. <tr>
  353. <td>Reccords Score</td>
  354. <td><input type="text" name="rec_score" id="rec_score" maxlength="4" readonly onFocus="calc1()" /></td>
  355. <td><input type="text" name="rec_max_score" id="rec_max_score" maxlength="4" readonly onFocus="avgcalc1()"/></td>
  356. <td><input type="text" name="rec_percent" id="rec_percent" maxlength="4" readonly onFocus="crosscons()" /></td>
  357. </tr>
  358. <tr>
  359. <td>Overall Plant EHS Score</td>
  360. <td><input type="text" name="over_score" id="over_score" maxlength="4" readonly onFocus="ov_sc()" /></td>
  361. <td><input type="text" name="over_max_score" id="over_max_score" maxlength="4" readonly onFocus="avgtot()" /></td>
  362. <td><input type="text" name="over_percent" id="over_percent" maxlength="4" readonly onFocus="totagg()" /></td>
  363. </tr>
  364.  
  365. </table>
  366. <table border="0" width="1000" >
  367. <tr>
  368. <td>&nbsp;</td>
  369. </tr>
  370. <tr>
  371. <td colspan="6" align="center">
  372. <a href="#" onClick="checkmand();"><img src="images/Submit.jpg" style="border:none" /></a> </td>
  373. </tr>
  374. <tr>
  375. <td>&nbsp;</td>
  376. </tr>
  377. </table>
  378. <br />
  379.  
  380. </form>
  381. </body>
  382.  
  383.  
  384. <!--valid.js find it below-->
  385.  
  386. // JavaScript Document
  387. function checkmand()
  388. {
  389. var d=document.ehs_form;
  390.  
  391. if(d.oper_name.value=="")
  392. {
  393. alert('Please enter the operator name');
  394. d.oper_name.focus();
  395. return false;
  396. }
  397. else if(d.from_dts1.value=="")
  398. {
  399. alert('Please select the date');
  400. d.from_dts1.focus();
  401. return false;
  402. }
  403. else if(d.qua_ex_nam.value=="")
  404. {
  405. alert('Please enter the quality executive name');
  406. d.qua_ex_nam.focus();
  407. return false;
  408. }
  409. }
  410.  
  411. function c1()
  412. {
  413. //alert('ckd');
  414. var d=document.ehs_form;
  415.  
  416. if(d.y_n_1.value=='N')
  417. {
  418. d.sco_1.value='0.00';
  419. d.sco_1.disabled=true;
  420. d.wei_sco1.value='0.00';
  421. }
  422. else
  423. {
  424. d.sco_1.disabled=false;
  425. }
  426.  
  427. if(d.y_n_2.value=='N')
  428. {
  429. d.sco_2.value='0.00';
  430. d.sco_2.disabled=true;
  431. d.wei_sco2.value='0.00';
  432. }
  433. else
  434. {
  435. d.sco_2.disabled=false;
  436. }
  437.  
  438. if(d.y_n_3.value=='N')
  439. {
  440. d.sco_3.value='0.00';
  441. d.sco_3.disabled=true;
  442. d.wei_sco3.value='0.00';
  443. }
  444. else
  445. {
  446. d.sco_3.disabled=false;
  447. }
  448.  
  449. if(d.y_n_4.value=='N')
  450. {
  451. d.sco_4.value='0.00';
  452. d.sco_4.disabled=true;
  453. d.wei_sco4.value='0.00';
  454. }
  455. else
  456. {
  457. d.sco_4.disabled=false;
  458. }
  459.  
  460. if(d.y_n_5.value=='N')
  461. {
  462. d.sco_5.value='0.00';
  463. d.sco_5.disabled=true;
  464. d.wei_sco5.value='0.00';
  465. }
  466. else
  467. {
  468. d.sco_5.disabled=false;
  469. }
  470.  
  471.  
  472. if(d.y_n_6.value=='N')
  473. {
  474. d.sco_6.value='0.00';
  475. d.sco_6.disabled=true;
  476. d.wei_sco6.value='0.00';
  477. }
  478. else
  479. {
  480. d.sco_6.disabled=false;
  481. }
  482.  
  483. if(d.y_n_7.value=='N')
  484. {
  485. d.sco_7.value='0.00';
  486. d.sco_7.disabled=true;
  487. d.wei_sco7.value='0.00';
  488. }
  489. else
  490. {
  491. d.sco_7.disabled=false;
  492. }
  493.  
  494. if(d.y_n_8.value=='N')
  495. {
  496. d.sco_8.value='0.00';
  497. d.sco_8.disabled=true;
  498. d.wei_sco8.value='0.00';
  499. }
  500. else
  501. {
  502. d.sco_8.disabled=false;
  503. }
  504.  
  505. if(d.y_n_9.value=='N')
  506. {
  507. d.sco_9.value='0.00';
  508. d.sco_9.disabled=true;
  509. d.wei_sco9.value='0.00';
  510. }
  511. else
  512. {
  513. d.sco_9.disabled=false;
  514. }
  515.  
  516. if(d.y_n_10.value=='N')
  517. {
  518. d.sco_10.value='0.00';
  519. d.sco_10.disabled=true;
  520. d.wei_sco10.value='0.00';
  521. }
  522. else
  523. {
  524. d.sco_10.disabled=false;
  525. }
  526.  
  527. if(d.y_n_11.value=='N')
  528. {
  529. d.sco_11.value='0.00';
  530. d.sco_11.disabled=true;
  531. d.wei_sco11.value='0.00';
  532. }
  533. else
  534. {
  535. d.sco_11.disabled=false;
  536. }
  537.  
  538. if(d.y_n_12.value=='N')
  539. {
  540. d.sco_12.value='0.00';
  541. d.sco_12.disabled=true;
  542. d.wei_sco12.value='0.00';
  543. }
  544. else
  545. {
  546. d.sco_12.disabled=false;
  547. }
  548.  
  549. if(d.y_n_13.value=='N')
  550. {
  551. d.sco_13.value='0.00';
  552. d.sco_13.disabled=true;
  553. d.wei_sco13.value='0.00';
  554. }
  555. else
  556. {
  557. d.sco_13.disabled=false;
  558. }
  559.  
  560. if(d.y_n_14.value=='N')
  561. {
  562. d.sco_14.value='0.00';
  563. d.sco_14.disabled=true;
  564. d.wei_sco14.value='0.00';
  565. }
  566. else
  567. {
  568. d.sco_14.disabled=false;
  569. }
  570.  
  571. if(d.y_n_15.value=='N')
  572. {
  573. d.sco_15.value='0.00';
  574. d.sco_15.disabled=true;
  575. d.wei_sco15.value='0.00';
  576. }
  577. else
  578. {
  579. d.sco_15.disabled=false;
  580. }
  581.  
  582. if(d.y_n_16.value=='N')
  583. {
  584. d.sco_16.value='0.00';
  585. d.sco_16.disabled=true;
  586. d.wei_sco16.value='0.00';
  587. }
  588. else
  589. {
  590. d.sco_16.disabled=false;
  591. }
  592.  
  593. if(d.y_n_17.value=='N')
  594. {
  595. d.sco_17.value='0.00';
  596. d.sco_17.disabled=true;
  597. d.wei_sco17.value='0.00';
  598. }
  599. else
  600. {
  601. d.sco_17.disabled=false;
  602. }
  603.  
  604. if(d.y_n_18.value=='N')
  605. {
  606. d.sco_18.value='0.00';
  607. d.sco_18.disabled=true;
  608. d.wei_sco18.value='0.00';
  609. }
  610. else
  611. {
  612. d.sco_18.disabled=false;
  613. }
  614.  
  615. if(d.y_n_19.value=='N')
  616. {
  617. d.sco_19.value='0.00';
  618. d.sco_19.disabled=true;
  619. d.wei_sco19.value='0.00';
  620. }
  621. else
  622. {
  623. d.sco_19.disabled=false;
  624. }
  625.  
  626. if(d.y_n_20.value=='N')
  627. {
  628. d.sco_20.value='0.00';
  629. d.sco_20.disabled=true;
  630. d.wei_sco20.value='0.00';
  631. }
  632. else
  633. {
  634. d.sco_20.disabled=false;
  635. }
  636.  
  637. if(d.y_n_21.value=='N')
  638. {
  639. d.sco_21.value='0.00';
  640. d.sco_21.disabled=true;
  641. d.wei_sco21.value='0.00';
  642. }
  643. else
  644. {
  645. d.sco_21.disabled=false;
  646. }
  647.  
  648. if(d.y_n_22.value=='N')
  649. {
  650. d.sco_22.value='0.00';
  651. d.sco_22.disabled=true;
  652. d.wei_sco22.value='0.00';
  653. }
  654. else
  655. {
  656. d.sco_22.disabled=false;
  657. }
  658.  
  659. if(d.y_n_23.value=='N')
  660. {
  661. d.sco_23.value='0.00';
  662. d.sco_23.disabled=true;
  663. d.wei_sco23.value='0.00';
  664. }
  665. else
  666. {
  667. d.sco_23.disabled=false;
  668. }
  669.  
  670. if(d.y_n_24.value=='N')
  671. {
  672. d.sco_24.value='0.00';
  673. d.sco_24.disabled=true;
  674. d.wei_sco24.value='0.00';
  675. }
  676. else
  677. {
  678. d.sco_24.disabled=false;
  679. }
  680. calc1();
  681. ov_sc();
  682. avgcalc1();
  683. vgtot();
  684. crosscons();
  685. totagg();
  686. }
  687.  
  688. function e1()
  689. {
  690. var d=document.ehs_form;
  691. var a1=(d.sco_1.value * 1.00); var a2=(d.sco_2.value * 1.00); var a3=(d.sco_3.value * 0.50); var a4=(d.sco_4.value * 0.25);
  692. var a5=(d.sco_5.value * 0.25); var a6=(d.sco_6.value * 1.00); var a7=(d.sco_7.value * 1.00); var a8=(d.sco_8.value * 1.00);
  693. var a9=(d.sco_9.value * 1.00); var a10=(d.sco_10.value * 0.50); var a11=(d.sco_11.value * 0.50); var a12=(d.sco_12.value * 0.50);
  694. var a13=(d.sco_13.value * 0.25); var a14=(d.sco_14.value * 0.25); var a15=(d.sco_15.value * 1.00);
  695. var a16=(d.sco_16.value * 1.00); var a17=(d.sco_17.value * 1.00); var a18=(d.sco_18.value * 0.50); var a19=(d.sco_19.value * 0.50);var a20=(d.sco_20.value * 1.00); var a21=(d.sco_21.value * 0.25); var a22=(d.sco_22.value * 0.25); var a23=(d.sco_23.value * 0.25);
  696. var a24=(d.sco_24.value * 0.25);
  697.  
  698. d.wei_sco1.value=a1.toFixed(2); d.wei_sco2.value=a2.toFixed(2); d.wei_sco3.value=a3.toFixed(2); d.wei_sco4.value=a4.toFixed(2);
  699. d.wei_sco5.value=a5.toFixed(2); d.wei_sco6.value=a6.toFixed(2); d.wei_sco7.value=a7.toFixed(2); d.wei_sco8.value=a8.toFixed(2);
  700. d.wei_sco9.value=a9.toFixed(2); d.wei_sco10.value=a10.toFixed(2); d.wei_sco11.value=a11.toFixed(2); d.wei_sco12.value=a12.toFixed(2);
  701. d.wei_sco13.value=a13.toFixed(2); d.wei_sco14.value=a14.toFixed(2); d.wei_sco15.value=a15.toFixed(2); d.wei_sco16.value=a16.toFixed(2);
  702. d.wei_sco17.value=a17.toFixed(2); d.wei_sco18.value=a18.toFixed(2); d.wei_sco19.value=a19.toFixed(2);d.wei_sco20.value=a20.toFixed(2);
  703. d.wei_sco21.value=a21.toFixed(2); d.wei_sco22.value=a22.toFixed(2); d.wei_sco23.value=a23.toFixed(2); d.wei_sco24.value=a24.toFixed(2);
  704.  
  705.  
  706. }
  707.  
  708. function d1()
  709. {
  710. //alert('howhow');
  711.  
  712. var d=document.ehs_form;
  713. var a1=(d.sco_1.value * 1.00); var a2=(d.sco_2.value * 1.00); var a3=(d.sco_3.value * 0.50); var a4=(d.sco_4.value * 0.25);
  714. var a5=(d.sco_5.value * 0.25); var a6=(d.sco_6.value * 1.00); var a7=(d.sco_7.value * 1.00); var a8=(d.sco_8.value * 1.00);
  715. var a9=(d.sco_9.value * 1.00); var a10=(d.sco_10.value * 0.50); var a11=(d.sco_11.value * 0.50); var a12=(d.sco_12.value * 0.50);
  716. var a13=(d.sco_13.value * 0.25); var a14=(d.sco_14.value * 0.25); var a15=(d.sco_15.value * 1.00);
  717. var a16=(d.sco_16.value * 1.00); var a17=(d.sco_17.value * 1.00); var a18=(d.sco_18.value * 0.50); var a19=(d.sco_19.value * 0.50);var a20=(d.sco_20.value * 1.00); var a21=(d.sco_21.value * 0.25); var a22=(d.sco_22.value * 0.25); var a23=(d.sco_23.value * 0.25);
  718. var a24=(d.sco_24.value * 0.25);
  719.  
  720. d.wei_sco1.value=a1.toFixed(2); d.wei_sco2.value=a2.toFixed(2); d.wei_sco3.value=a3.toFixed(2); d.wei_sco4.value=a4.toFixed(2);
  721. d.wei_sco5.value=a5.toFixed(2); d.wei_sco6.value=a6.toFixed(2); d.wei_sco7.value=a7.toFixed(2); d.wei_sco8.value=a8.toFixed(2);
  722. d.wei_sco9.value=a9.toFixed(2); d.wei_sco10.value=a10.toFixed(2); d.wei_sco11.value=a11.toFixed(2); d.wei_sco12.value=a12.toFixed(2);
  723. d.wei_sco13.value=a13.toFixed(2); d.wei_sco14.value=a14.toFixed(2); d.wei_sco15.value=a15.toFixed(2); d.wei_sco16.value=a16.toFixed(2);
  724. d.wei_sco17.value=a17.toFixed(2); d.wei_sco18.value=a18.toFixed(2); d.wei_sco19.value=a19.toFixed(2); d.wei_sco20.value=a20.toFixed(2);
  725. d.wei_sco21.value=a21.toFixed(2); d.wei_sco22.value=a22.toFixed(2); d.wei_sco23.value=a23.toFixed(2); d.wei_sco24.value=a24.toFixed(2);
  726. calc1();
  727. crosscons();
  728. totagg();
  729.  
  730. }
  731.  
  732. function calc1()
  733. {
  734. var d=document.ehs_form;
  735. var b1=parseFloat(d.wei_sco1.value)+parseFloat(d.wei_sco2.value)+parseFloat(d.wei_sco3.value)+parseFloat(d.wei_sco4.value)+parseFloat(d.wei_sco5.value);
  736. var b2=parseFloat(d.wei_sco6.value)+parseFloat(d.wei_sco7.value)+parseFloat(d.wei_sco8.value)+parseFloat(d.wei_sco9.value)+parseFloat(d.wei_sco10.value)+parseFloat(d.wei_sco11.value)+parseFloat(d.wei_sco12.value)+parseFloat(d.wei_sco13.value)+parseFloat(d.wei_sco14.value);
  737. var b3=parseFloat(d.wei_sco15.value)+parseFloat(d.wei_sco16.value)+parseFloat(d.wei_sco17.value)+parseFloat(d.wei_sco18.value)+parseFloat(d.wei_sco19.value);
  738. var b4=parseFloat(d.wei_sco20.value)+parseFloat(d.wei_sco21.value)+parseFloat(d.wei_sco22.value)+parseFloat(d.wei_sco23.value)+parseFloat(d.wei_sco24.value);
  739.  
  740.  
  741. d.es_score.value=b1.toFixed(2);
  742. d.hss_score.value=b2.toFixed(2);
  743. d.hk_score.value=b3.toFixed(2);
  744. d.rec_score.value=b4.toFixed(2);
  745. ov_sc();
  746. }
  747.  
  748. function ov_sc()
  749. {
  750. var d=document.ehs_form;
  751. var f1=parseFloat(d.es_score.value)+parseFloat(d.hss_score.value)+parseFloat(d.hk_score.value)+parseFloat(d.rec_score.value);
  752.  
  753. d.over_score.value=f1.toFixed(2);
  754. }
  755.  
  756. function avgcalc1()
  757. {
  758.  
  759. var d=document.ehs_form;
  760. if(d.y_n_1.value=='Y')
  761. {
  762. var c1='1.00'; //alert('a');
  763. }
  764. else
  765. {
  766. var c1='0.00'; //alert('b');
  767. }
  768.  
  769. if(d.y_n_2.value=='Y')
  770. {
  771. var c2='1.00';
  772. }
  773. else
  774. {
  775. var c2='0.00';
  776. }
  777.  
  778. if(d.y_n_3.value=='Y')
  779. {
  780. var c3='0.50';
  781. }
  782. else
  783. {
  784. var c3='0.00';
  785. }
  786.  
  787. if(d.y_n_4.value=='Y')
  788. {
  789. var c4='0.25';
  790. }
  791. else
  792. {
  793. var c4='0.00';
  794. }
  795.  
  796. if(d.y_n_5.value=='Y')
  797. {
  798. var c5='0.25';
  799. }
  800. else
  801. {
  802. var c5='0.00';
  803. }
  804.  
  805. if(d.y_n_6.value=='Y')
  806. {
  807. var c6='1.00'; //alert('a');
  808. }
  809. else
  810. {
  811. var c6='0.00'; //alert('b');
  812. }
  813.  
  814. if(d.y_n_7.value=='Y')
  815. {
  816. var c7='1.00';
  817. }
  818. else
  819. {
  820. var c7='0.00';
  821. }
  822.  
  823. if(d.y_n_8.value=='Y')
  824. {
  825. var c8='1.00';
  826. }
  827. else
  828. {
  829. var c8='0.00';
  830. }
  831.  
  832. if(d.y_n_9.value=='Y')
  833. {
  834. var c9='1.00';
  835. }
  836. else
  837. {
  838. var c9='0.00';
  839. }
  840.  
  841. if(d.y_n_10.value=='Y')
  842. {
  843. var c10='0.50';
  844. }
  845. else
  846. {
  847. var c10='0.00';
  848. }
  849.  
  850. if(d.y_n_11.value=='Y')
  851. {
  852. var c11='0.50';
  853. }
  854. else
  855. {
  856. var c11='0.00';
  857. }
  858.  
  859. if(d.y_n_12.value=='Y')
  860. {
  861. var c12='0.50';
  862. }
  863. else
  864. {
  865. var c12='0.00';
  866. }
  867.  
  868. if(d.y_n_13.value=='Y')
  869. {
  870. var c13='0.25';
  871. }
  872. else
  873. {
  874. var c13='0.00';
  875. }
  876.  
  877. if(d.y_n_14.value=='Y')
  878. {
  879. var c14='0.25';
  880. }
  881. else
  882. {
  883. var c14='0.00';
  884. }
  885.  
  886. if(d.y_n_15.value=='Y')
  887. {
  888. var c15='1.00'; //alert('a');
  889. }
  890. else
  891. {
  892. var c15='0.00'; //alert('b');
  893. }
  894.  
  895. if(d.y_n_16.value=='Y')
  896. {
  897. var c16='1.00';
  898. }
  899. else
  900. {
  901. var c16='0.00';
  902. }
  903.  
  904. if(d.y_n_17.value=='Y')
  905. {
  906. var c17='1.00';
  907. }
  908. else
  909. {
  910. var c17='0.00';
  911. }
  912.  
  913. if(d.y_n_18.value=='Y')
  914. {
  915. var c18='0.50';
  916. }
  917. else
  918. {
  919. var c18='0.00';
  920. }
  921.  
  922. if(d.y_n_19.value=='Y')
  923. {
  924. var c19='0.50';
  925. }
  926. else
  927. {
  928. var c19='0.00';
  929. }
  930.  
  931. if(d.y_n_20.value=='Y')
  932. {
  933. var c20='1.00'; //alert('a');
  934. }
  935. else
  936. {
  937. var c20='0.00'; //alert('b');
  938. }
  939.  
  940.  
  941. if(d.y_n_21.value=='Y')
  942. {
  943. var c21='0.25';
  944. }
  945. else
  946. {
  947. var c21='0.00';
  948. }
  949.  
  950. if(d.y_n_22.value=='Y')
  951. {
  952. var c22='0.25';
  953. }
  954. else
  955. {
  956. var c22='0.00';
  957. }
  958.  
  959. if(d.y_n_23.value=='Y')
  960. {
  961. var c23='0.25';
  962. }
  963. else
  964. {
  965. var c23='0.00';
  966. }
  967.  
  968. if(d.y_n_24.value=='Y')
  969. {
  970. var c24='0.25';
  971. }
  972. else
  973. {
  974. var c24='0.00';
  975. }
  976.  
  977. var v1=parseFloat(c1)+parseFloat(c2)+parseFloat(c3)+parseFloat(c4)+parseFloat(c5);
  978. var v2=parseFloat(c6)+parseFloat(c7)+parseFloat(c8)+parseFloat(c9)+parseFloat(c10)+parseFloat(c11)+parseFloat(c12)+parseFloat(c13)+parseFloat(c14);
  979. var v3=parseFloat(c15)+parseFloat(c16)+parseFloat(c17)+parseFloat(c18)+parseFloat(c19);
  980. var v4=parseFloat(c20)+parseFloat(c21)+parseFloat(c22)+parseFloat(c23)+parseFloat(c24);
  981.  
  982. d.es_max_score.value=v1.toFixed(2);
  983. d.hss_max_score.value=v2.toFixed(2);
  984. d.hk_max_score.value=v3.toFixed(2);
  985. d.rec_max_score.value=v4.toFixed(2);
  986. avgtot();
  987. }
  988.  
  989. function avgtot()
  990. {
  991. var d=document.ehs_form;
  992.  
  993. var t1=parseFloat(d.es_max_score.value)+parseFloat(d.hss_max_score.value)+parseFloat(d.hk_max_score.value)+parseFloat(d.rec_max_score.value);
  994.  
  995. d.over_max_score.value=t1.toFixed(2);
  996. }
  997.  
  998. function crosscons()
  999. {
  1000. var d=document.ehs_form;
  1001.  
  1002. var intoval_a=(parseFloat(d.es_score.value)/parseFloat(d.es_max_score.value));
  1003. var divval_a=parseFloat(intoval_a)*100;
  1004. // alert(d.es_score.value);
  1005. var intoval_b=(parseFloat(d.hss_score.value)/parseFloat(d.hss_max_score.value));
  1006. var divval_b=parseFloat(intoval_b)*100;
  1007.  
  1008. var intoval_c=(parseFloat(d.hk_score.value)/parseFloat(d.hk_max_score.value));
  1009. var divval_c=parseFloat(intoval_c)*100;
  1010.  
  1011. var intoval_d=(parseFloat(d.rec_score.value)/parseFloat(d.rec_max_score.value));
  1012. var divval_d=parseFloat(intoval_d)*100;
  1013.  
  1014. d.es_percent.value=divval_a.toFixed(2);
  1015. d.hss_percent.value=divval_b.toFixed(2);
  1016. d.hk_percent.value=divval_c.toFixed(2);
  1017. d.rec_percent.value=divval_d.toFixed(2);
  1018. }
  1019.  
  1020. function totagg()
  1021. {
  1022. var d=document.ehs_form;
  1023.  
  1024. var tot_a=parseFloat(d.es_percent.value)+parseFloat(d.hss_percent.value)+parseFloat(d.hk_percent.value)+parseFloat(d.rec_percent.value);
  1025. var fin_tot=parseFloat(tot_a)/4;
  1026.  
  1027. d.over_percent.value=fin_tot.toFixed(2);
  1028. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.