Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <div id = 'state'>
  2. <%= select_tag :state, options_for_select(us_states) %>
  3. </div>
  4. <br>
  5. <div id = 'prov' >
  6. <%= select_tag :provinces, options_for_select(canadian_provinces) %>
  7. </div>
  8. <br>
  9. <div id = 'country'>
  10.  
  11. <%= select_tag :country, options_for_select(country), :onchange => "myFunction()" %>
  12. </div>
  13.  
  14.  
  15. <script>
  16. function myFunction() {$(this).find(":selected").val();
  17.  
  18. if (this.val = 'CAN')
  19. var y = document.getElementById("prov");
  20. if (y.style.display === "none") {
  21. y.style.display = "block";
  22. } else {
  23. y.style.display = "none";
  24. }
  25. }
  26.  
  27. else
  28. {
  29.  
  30. var x = document.getElementById("state");
  31. if (x.style.display === "none") {
  32. x.style.display = "block";
  33. } else {
  34. x.style.display = "none";
  35. }
  36. }
  37. }
  38.  
  39.  
  40. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement