Advertisement
Guest User

Untitled

a guest
May 10th, 2012
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var converter = function() {
  2.                 var = from = document.units.elements.from,
  3.                 fromWhat = document.units.elements.fromWhat,
  4.                 to = document.units.elements.to,
  5.                 toWhat = document.units.elements.toWhat;
  6.  
  7.                 if (fromWhat.value === "Convert from" && toWhat.value === "Convert to") {
  8.                         alert("Please choose what you want to convert, and what you want it be converted to.");
  9.                         } else if (fromWhat.value === "Convert from") {
  10.                                 alert("Please choose what you want to convert.");
  11.                         } else if (toWhat.value === "Convert to") {
  12.                                 alert("Please choose what you want to convert to.");
  13.                         } else if ((isNaN(from.value) === true) || (isNaN(to.value) === true) || (from === null) || (from.value === undefined)) {
  14.                                 alert("Please enter a number.");
  15.                         }
  16.                
  17.     else {
  18.                         to.value = fromWhat.value*fromWhat.value/toWhat.value;  
  19.        
  20.     }
  21.     return false;
  22. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement