Prefill Form with Query String Parameters
You can pass Query String parameters to the Form to pre fill fields. This can be used to, for instance, pre-select a value by changing the url with which you send users to the page containing the Form.
$(document).on("postRender.openform", function (event, control, moduleid, sf ) {
var title = control.childrenByPropertyId["Sujet"];
if(title){
var sujet = getParameterByName('sujet');
title.setValue(sujet);
}
});
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
Updated about 6 years ago