Take the 2-minute tour ×

I've came across a requirement where I need to fill some of the fields in newform.

So basically we start from view item, where we can see an existing item in a list, then we click something like move to new form, and the fields from this item, should be filled in the new form page, and after clicking ok, the new item should be added to the list.

I was thinking doing this with the jquery, where on click I could call a "new item form" with a query string "?sameitem={itemId}" and with javascript, i could query this list for that item and then dynamically fill all the fields in the form.

Could anyone assist me with a javascript code for sharepoint 2007? Or foward me to a existing kind of solution?

Also important is that i have to do it dynamically i don't know on what content type this feature will be used, so i need to retrieve from CT the path to the new form page, as it can be different from the default, and also using dom to find the correct field and fill them in.

Any idea?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I would use jQuery and SPServices in the custom new item form and get the existing item with SPServices function GetListItems (example).

So something like this

var existingID = 5; // GET THIS FROM QUERYSTRING

$(document).ready(function() {
    operation: "GetListItems",
    async: false,
    listName: "Announcements",
    CAMLViewFields: "<ViewFields><FieldRef Name='FieldA' /><FieldRef Name='FieldB' /></ViewFields>",
    Query: "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Integer'>" + existingID + "</Value></Eq></Where></Query>"
    completefunc: function (xData, Status) {
      $("#fieldARef").val($(this).attr("ows_FieldA")); // get reference to field's HTML element in the form using jQuery and put in the value you get from SPServices     

Haven't tested this code, just took SPServices example and modified it to suit your scenario.

share|improve this answer
Ok thank you very much ill try! –  Shkipper Feb 27 '13 at 14:19

Your Answer


