Hi Guys,
Below is my use case:
Need to fill the form fields using the query parameters once the URL is hit. The form components are core components [not the AEM Forms]. Any working code [preferably in sightly] available on this?
Thanks,
Kiran Vedantam.
Solved! Go to Solution.
Views
Replies
Total Likes
Thanks for your response. But I have achived this using the global "request" object that is available in sightly like this: ${request.parameterMap.fieldName} and add this to the value attribute of the HTML.
Thanks,
Kiran Vedantam.
Hi @Kiran_Vedantam,
We can achieve this in JS. Please find below for the sample snippet. Based on the pattern you get your queryParameters and form field name attribute, we can amend the logic accordingly.
(() => { $(document).ready(() => { var urlParams = new URLSearchParams(window.location.search); if(urlParams.has("firstName")){ console.log("Has firstName as Query Param"); $("input[name='firstName']").val(urlParams.get("firstName")); } if(urlParams.has("country")){ // for select, value set should be <option> value for it to display the respective value as selected $("select[name='country']").val(urlParams.get("country")); } }); }) ();
Views
Replies
Total Likes
Thanks for your response. But I have achived this using the global "request" object that is available in sightly like this: ${request.parameterMap.fieldName} and add this to the value attribute of the HTML.
Thanks,
Kiran Vedantam.
Views
Likes
Replies
Views
Likes
Replies