Browse Source

Submit form when all values are entered

Andrew Kane 10 years ago
parent
commit
b482e66e75
1 changed files with 14 additions and 6 deletions
  1. 14 6
      app/views/blazer/queries/show.html.erb

+ 14 - 6
app/views/blazer/queries/show.html.erb

@@ -124,15 +124,23 @@
       $("#results").html(data);
       $("#results table").stupidtable().stickyTableHeaders({fixedOffset: 60});
     });
-
-    $(".form-inline input, .form-inline select").change( function () {
-      if ($(this).val() != "") {
-        $(this).closest("form").submit();
-      }
-    });
   </script>
 <% end %>
 
 <script>
   hljs.initHighlightingOnLoad();
+
+  $(".form-inline input, .form-inline select").change( function () {
+    // see if all value are entered
+    var $form = $(this).closest("form");
+    var completed = true;
+    $form.find("input[name], select").each( function() {
+      if ($(this).val() == "") {
+        completed = false;
+      }
+    });
+    if (completed) {
+      $form.submit();
+    }
+  });
 </script>