Guest User

Untitled

a guest
Jun 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. /////////////// API Functions to manipulate forms on the page //////////////
  2.  
  3. // Check a checkbox on a form
  4. // Returns false if element does not exist, or is disabled
  5. function FormCheck(strFormName, strInputName, strInputValue)
  6. {
  7. var strXPath = "";
  8.  
  9. // Form name is optional, include it if necessary
  10. if (strFormName)
  11. strXPath += '//form[@name=\'' + strFormName + '\']';
  12.  
  13. // Input name is mandatory (else we cannot find the input box...)
  14. strXPath += '//input[@name=\'' + strInputName + '\'';
  15.  
  16. // Input value is also optional
  17. if (strInputValue)
  18. strXPath += ' and @value=\'' + strInputValue + '\'';
  19. strXPath += ']';
  20.  
  21. var elem = document.evaluate(strXPath, document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
  22.  
  23. // Return without action if element does not exist or is disabled
  24. if (!elem || elem.disabled)
  25. return false;
  26.  
  27. // Otherwise check the box and return true
  28. elem.checked = "checked";
  29. return true;
  30. }
Add Comment
Please, Sign In to add comment