• Resolved geertvanderheide

    (@geertvanderheide)


    I’m looking to pre-fill a field with a value that will be passed to the page via the URL (GET variable / query parameter). Is this supported for this plugin and if so, how do I go about this? Thanks in advance for any assistance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    The following code placed into the “General Settiongs >> Edit Scripts” are of the plugin can help. With this sample script the field with ID “fieldname2” will be pre-filled, change the field ID (line #3 of the script) to match the ID of the field in your form:

    function loaddata()
    {
        var fieldid = "fieldname2";
    	try {
    		var url = String(document.location);
    	        document.getElementById(fieldid+"_1").value = url.substr( url.indexOf("=")+1);
    	} catch (e) {
    	    setTimeout('loaddata()',100);
    	}
    }
    loaddata();

    If you need a more detailed assistance please open a ticket at https://apphourbooking.dwbooster.com/contact-us indicating the address of the page that contains the form.

    Thank you for using the plugin!

    Thread Starter geertvanderheide

    (@geertvanderheide)

    Thank you for your reply! With your example I was able to make it work.

    Just a tip for the future: you might want to consider implementing a custom Javascript event like “ahbFormReady” or similar, then firing it when the form is fully loaded and ready, so that setTimeout checks are no longer necessary. It’s not a huge thing, but it could make things even better.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Thank you for your feedback! Yes, we agree that’s a better solution and we will implement it in a future update.

    Thank you for using the plugin!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Pre-fill field with GET variable / query parameter?’ is closed to new replies.