Advertisement
Guest User

Untitled

a guest
Jan 30th, 2013
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <script type="text/javascript" src="http://form.jotform.me/jsform/30295750834457"></script>
  2. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
  3. <script>
  4. $.noConflict();
  5. (function($){
  6. var
  7. jotform_id = "#30295750834457", //usually jotform id, needed to reference the iframe
  8. independent_id = '#input_3', //replace by the id of the master/depended on, state
  9. dependent_id = '#input_4' //replace by the id of the slave/dependent dropdown select, counties
  10. ;
  11.  
  12. $(document).ready(function(){
  13. //make sure jotform is loaded
  14. $(jotform_id).load(function() {
  15.  
  16. $independent = $(this).contents().find(independent_id);
  17. $dependent = $(this).contents().find(dependent_id);
  18. //bind change event
  19. $independent.change(function(){
  20. //trim
  21. var current_state = $independent.val().replace(/^\s+|\s+$/g, '');
  22. //alert('state dropdown was changed to: ' + current_state);
  23.  
  24. //iterate options, check last 2 characters if match
  25. $dependent.find('option').each(function(){
  26. if ($(this).val().substr(-2) == current_state)
  27. $(this).show();
  28. else
  29. $(this).hide();
  30. });
  31.  
  32. });
  33. })
  34. });
  35. })(jQuery);
  36. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement