You are viewing limited content. For full access, please sign in.

Question

Question

I have a java script in an existing Laserfiche 11 classic Form, I've copied it and put it into an upgraded form for Laserfiche 12 Forms. Why doesn't work and what can I use alternatively?

asked on June 11

We have an existing Google address java script lookup that was in a Laserfiche 11 classic form. Now I'm trying to rewrite the form in Laserfiche 12 and after copying and pasting it, it does not work. What is the work around for this?

Thanks,

Caroline

0 0

Replies

replied on June 11

Note that the structure in the Layout Designer and in the Classic Designer are significantly different.  JavaScript written for one cannot be used in the other and vice-versa.  The code will need to be re-written to be used in the Layout Designer and there are limitations to what the code in the Layout Designer can do (it doesn't have direct access to the Form's structure and components and instead makes changes to the form via the LFForm object and it's properties and functions).

We would likely need to see your existing code to be able to provide any assistance with re-writing it.

3 0
replied on June 16

Hi Matthew,

I watched the presentation you recommended and tried to rewrite the code, but it's just not working. Here is the original code. Can you point me in the right direction, resources to make this work?  

$.cachedScript = function(url, options){

                options = $.extend(options || {}, {

                                dataType: "script",

                                cache: true,

                                url: url

                });

                return $.ajax(options);

};

 

var gUrl = "//maps.googleapis.com/maps/apikey=places";

var gcUrl = "//ubilabs.github.io/geocomplete/jquery.geocomplete.js";

 

$.cachedScript(gUrl).done(function(){

                $.cachedScript(gcUrl).done(function(script, textStatus){

 

                                var options = {

                                                                                                details:"form"

                                }

                               

                                // ID for the Street Address input on the Address widget

                                $("#Field116\\(1\\)_DSG0").geocomplete(options)

                                .bind("geocode:result",           function(event, result){

                                               

                                                // https://developers.google.com/maps/documentation/geocoding/#Types

                                                var ac = result.address_components;

                                                var lat = result.geometry.location.lat();

                                                var lng = result.geometry.location.lng();

                                                var c = {};

                                                $.each(ac, function(key1, val1) {

                                                                $.each(val1.types, function(key2, val2){

                                                                                c[val2]=val1.short_name

                                                                });

                                                })

                                               

                                                var lo = c.locality;

                                                if(lo === undefined)

                                                                lo = c.postal_town;

                                                               

                                                // ID for the City input on the Address widget

                                                $("#Field116\\(1\\)_DSG2").val(lo);

                                                               

                                                var aal = c.administrative_area_level_1;

                                                if(aal === undefined)

                                                                aal = c.administrative_area_level_2;

                                               

                                                // ID for the State / Province / Region input on the Address widget

                                                $("#Field116\\(1\\)_DSG3").val(aal);

                                               

                                                var pc = c.postal_code;

                                                if(c.postal_code_suffix != undefined)

                                                                pc += "-" + c.postal_code_suffix;

                                               

                                                // ID for the Postal / Zip Code input on the Address widget

                                                $("#Field116\\(1\\)_DSG4").val(pc);

                                               

                                                // ID for the County input on the Address widget

                                                $("#Field116\\(1\\)_DSG5").val(c.county);

                                               

                                                $("#Field152\\(1\\)").val(lat);

                                                $("#Field153\\(1\\)").val(lng);             

                                                  

         

                                                // reformat Street Address to only have the address in it

                                                var addr = $("#Field116\\(1\\)_DSG0").val().split(",");

                                                $("#Field116\\(1\\)_DSG0").val(addr[0]);

 

                                                console.log(result);

                                });

     

    });

});

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.