I was just thinking of all the things I started this year but never finished.
One of them was the comments feature on this site. I wanted to have a link on every page so that people could send me feedback via a SharePoint list. I managed to get the basic feedback page created but never automated the population of the Page field that people were referring to.
So today I can tick this one off the list.
This is just a standard SharePoint Web Part Page. The Master Page for the site contains a hyperlink to this page so that users can comment on every page in the site.
Behind the scenes there is a sharepoint list with the fields that you see in the form on this page and I have signed up for alerts on this list.
The form is a Data Form which must be added to the page using SharePoint Designer. To add the form, insert the Data View from the the SPD Data View menu.
- Select the list that will hold the data from the data source list
- Select "View data"
- Hold down the <Ctrl> key and select all the field you want displayed in the form
- Select "Insert Selected Fields as", "New Item Form

You can add an action to the Submit button. Just right click the button and select "Form Actions". I have added a "Navigate To Page" function so that users don't end up at the default AllItems list view.

I populate the Page field on this form from the referring url buy using the following Java script added to the page. (the value in red is the name of the field I want to update).
<script language="javascript">
_spBodyOnLoadFunctionNames.push("fillDefaultValues");
function fillDefaultValues() {
setFormFieldName("Page");
}
function setFormFieldName(fieldName) {
var theInput = getTagFromIdentifierAndTitle("input","TextField",fieldName);
var txtValue=document.getElementById(theInput.id);
txtValue.value = document.referrer;
}
function getTagFromIdentifierAndTitle(tagName, identifier, title) {
var len = identifier.length;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i < tags.length; i++) {
var tempString = tags[i].id;
if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {
//tags[i].id.defaultValue = document.referrer;
return tags[i];
}
}
return null;
}
</script>
This script is derived from an awsome post on the SharePoint Designer team blog...
http://blogs.msdn.com/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx