Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 18th, 2010 | Syntax: None | Size: 1.50 KB | Hits: 47 | Expires: Never
Copy text to clipboard
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4.   <meta content="text/html; charset=ISO-8859-1"
  5.  http-equiv="content-type">
  6.   <title></title>
  7.  <script type="text/javascript">
  8.         function getnum ()
  9.         {
  10.                 var metric = (document.getElementById("metric").value) ;
  11.                 document.getElementById("impbox"). value = parseFloat(metric) / 2.54 / parseFloat(check_metric()) ;
  12.         }
  13.         function check_metric ()
  14.         {
  15.                 var item_checked = - 1 ;
  16.                 for (i=0; i<4; i=i + 1)
  17.                 {
  18.                         if (document.getElementsByName("metriccalc")[i].checked )
  19.                         item_checked = i ;
  20.                 }
  21.                         if (item_checked == 0)
  22.                                 {
  23.                                         return 10 ;
  24.                                 }
  25.                         if (item_checked == 1)
  26.                                 {
  27.                                         return  1 ;
  28.                                 }
  29.                         if (item_checked == 2)
  30.                                 {
  31.                                         return  .01 ;
  32.                                 }
  33.                         if (item_checked == 3)
  34.                                 {
  35.                                         return .00001 ;
  36.                                 }      
  37.                                         alert ("Please Select a Unit of Measure") ;
  38.                                         return 1 ;
  39.                                 }
  40.                 }
  41.  
  42.                         </script>
  43.   </head>
  44. <body>
  45.         <form id="step1" action="">
  46.                 <p>    
  47.                         <input type= "radio" name= "metriccalc" id="millimeters" value="mm" />
  48.                         <input type= "radio" name= "metriccalc" id="centimeters" value="cm" />
  49.                         <input type= "radio" name= "metriccalc" id="meters" value="m" />
  50.                         <input type= "radio" name= "metriccalc" id="kilometers" value="km" />
  51.                         <input type= "text" name="metric" id="metric" value="" />
  52.                         <input type= "button" value= "Click to Convert" onclick="getnum();" />
  53.                         <input type="text" name="impbox" id="impbox" />
  54.                         <br>
  55.                 </p>
  56.         </form>
  57. </body>
  58. </html>