Guest User

Untitled

a guest
Feb 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. function update_select_options(target, opts_array) {
  2. if ($(target).type.match('select')) { // Make sure we are dealing with a select field
  3. var obj = $(target);
  4.  
  5. // If any options are already in the select box, clear them
  6. // before creating the new options.
  7. if (obj.length > 0) {
  8. while (obj.hasChildNodes()) {
  9. obj.removeChild(obj.firstChild);
  10. }
  11. }
  12.  
  13. // Loop through each option in the array, adding them to the
  14. // select field.
  15. for (var i = 0; i < opts_array.length; i++) {
  16. var o = document.createElement('option');
  17. o.appendChild(document.createTextNode(opts_array[i][0]));
  18. o.setAttribute('value', opts_array[i][1]);
  19. $(target).appendChild(o);
  20. }
  21. }
  22. }
  23.  
  24. function update_submit_box(self) {
  25. var o = document.getElementById('school_submit');
  26. var loc = self.options[self.selectedIndex].text;
  27.  
  28. if (loc) {
  29. o.value = 'I am currently a student at ' + loc;
  30. o.style.display = 'block'
  31. } else {
  32. o.style.display = 'none'
  33. }
  34. }
Add Comment
Please, Sign In to add comment