Khandaker Toihidul Islam
Front-end Developer
React Js | Javascript | HTML | CSS | Bootstrap | Wordpress | PHP | Mysql

Contact form 7 set field value with get request

In my case [default:get] was not working therefore, I followed following steps

  1. [text* package id:package readonly ] for url = “http://www.example.se/package-quote/?package=Basic”
  2. Write jquery in footer.php
   <script type="text/javascript">
      jQuery(document).ready(function($) {
    	var getUrlParameter = function getUrlParameter(sParam) {
    		var sPageURL = window.location.search.substring(1),
    			sURLVariables = sPageURL.split('&'),
    			sParameterName,
    			i;
    		for (i = 0; i < sURLVariables.length; i++) {
    			sParameterName = sURLVariables[i].split('=');
    			if (sParameterName[0] === sParam) {
    				return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
    			}
    		}
    	};	
    	
    	var package = getUrlParameter('package');	
    	if(package !='undefined'){
    		$("#package").val(package);
    	}	  
      })
    </script> 

You may also like...

Leave a Reply