I put this in the parent window to get the query string from the URL and pass it to the Add new item link on the list view web part
<script type="text/javascript">
$(document).ready(function() {
//Gets the supplierID from the URL
var queryStringVals = $().SPServices.SPGetQueryString();
var supplierID = queryStringVals["FilterValue1"];
//replaces the onlick attribute of the add new item link with a NewForm.aspx and my query string variable
var incidentHrefandSupplierID = "http://sp2010/sites/MySite/Lists/MyList/NewForm.aspx?SupplierID=" + supplierID;
//console.log(incidentHrefandSupplierID);
$('#WebPartWPQ10 #idHomePageNewItem').attr('href', '#');
$('#WebPartWPQ10 #idHomePageNewItem').attr('onclick', function () {
return "javascript:showDialog('" + incidentHrefandSupplierID + "');"
//console.log(this.onclick);
});
});
//This function lives outside document.ready
function showDialog(url) {
var options = {
title: "New Item",
width: 800,
height: 600,
url: url };
SP.UI.ModalDialog.showModalDialog(options);
}
</script>
In the newform.aspx, I used this to get the query string and populate a lookup column.
<script type="text/javascript">
//Gets the supplierID from the URL and adds it to the Add new item link
$(document).ready(function() {
var queryStringVals = $().SPServices.SPGetQueryString();
var supplierID = queryStringVals["SupplierID"];
//console.log(supplierID);
$().SPServices.SPComplexToSimpleDropdown({
columnName: "SupplierID",
});
//like :contains but matches the text exactly
$.expr[':'].textEquals = function(a, i, m) {
return $(a).text().match("^" + m[3] + "$");
};
var selectedSupplierID = $("option:textEquals('" + supplierID + "')").val();
$("select[title=SupplierID]").val(selectedSupplierID);
$("select[title=SupplierID]").change();
});
</script>