Browse Source

Added the possibility to insert form data from URL Parameters

Manuel Gall 3 years ago
parent
commit
f570d826f5
1 changed files with 27 additions and 1 deletions
  1. 27 1
      template/form.html

+ 27 - 1
template/form.html

@@ -36,7 +36,22 @@
   <form id="fb-render">
     
   <script>
-  
+//https://stackoverflow.com/questions/5448545/how-to-retrieve-get-parameters-from-javascript
+function getSearchParameters() {
+    var prmstr = window.location.search.substr(1);
+    return prmstr != null && prmstr != "" ? transformToAssocArray(prmstr) : {};
+}
+
+function transformToAssocArray( prmstr ) {
+    var params = {};
+    var prmarr = prmstr.split("&");
+    for ( var i = 0; i < prmarr.length; i++) {
+        var tmparr = prmarr[i].split("=");
+        params[tmparr[0]] = tmparr[1];
+    }
+    return params;
+}
+
 function openlink(menuitem){
   var menu = { name: menuitem };
 
@@ -92,6 +107,17 @@ jQuery(function($) {
           this.name = this.value
           this.value = "true"
         });
+        
+        var urlpara = getSearchParameters();        
+        for (var key in urlpara) {
+          if (urlpara.hasOwnProperty(key)) {
+            
+            $( "input[name*='" + key + "']" ).val( urlpara[key] );
+
+           }
+        }
+        
+        
       },
       error: function (request, status, error) {
       }