Query Strings in Sitefinity w/ jQuery
Just a solution that I hope will help others in passing in query strings into forms in Sitefinity.
In this example a user clicks on a button to enquire about a particular product - The product code is passed via query string into a form.
Form field remains locked if a value is successfully passed and unlocked/empty if no query string is picked up.
Feel free to add any recommendations/modifications to this:
// This method retrieves the querystring value. If the querystring is missing it returns null. I’m not the author of the method :)function getQuerystring(key, default_) if (default_==null) default_=""; key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regex = new RegExp("[\\?&]"+key+"=([^&#]*)"); var cleanedString = regex.exec(window.location.href); if(cleanedString == null) return 'null' else return cleanedString [1];//Note: I targeted the input box with a wrapped CSS class called '.productCodeWrap'. You can target this any way you wish!$(document).ready(function() $(".productCodeWrap input.sfTxt").val(); var value = unescape(getQuerystring('pid','')); if(value != 'null' && value != '') $(".productCodeWrap input.sfTxt").val(value); $(".productCodeWrap input.sfTxt").attr('readonly','true'); $(".p );roductCodeWrap input.sfTxt").addClass("lockedField"); This code is very interesting, I want to learn more about this :)