I've got a List in SP2010 and am trying to update a value with a little javascript and I'm not sure what I ought to be doing.

I've set the default List Form WebPart to false, and added a custom list form.

I've got a FormField in my NewForm.aspx file that looks like this in Sharepoint Designer:

<td width="400px" valign="top" class="ms-formbody">
                            <SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="Polygon" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Polygon')}"/>
                            <SharePoint:FieldDescription runat="server" id="ff2description{$Pos}" FieldName="Polygon" ControlMode="New"/>

But I'm not sure what the id of the object ought to be, I gave a simple try with:


but that doesn't seem to be right.

I'm not finding it so easy to analyse the source that comes in my browser, it seems possible that the field gets an Id like:


which just seems crazy.

Am I going about this wrongly? Am I looking at this wrongly?


Basically, html field rendering element has attribute title equals to the field's title. It means that you can set value for text field (assuming it has name My Column and type text field):

$("input[title='My Column']").val("my val");

and this should be sufficient.

  • Really quite close here. This works for things like single lines and numbers, but not for the field I'm using which is a "Multiple lines of text" type. Does that make a difference?
    – Dave Alger
    Mar 20 '12 at 12:35
  • 1
    "Multiple lines of text" renders as textarea element (not input), so you need a little bit modify selector - $("textarea[title='My Column']").val("my val"); or you can even use more easy selector (but it also should be tested with different field types) - $("[title='My Column']").val("my val"); Mar 20 '12 at 12:45
  • I had tried the textarea version without success and was starting to wonder. I checked the properties of the field and it was set as being able to handle Rich Text (which I don't need). So I set it to just plain text and now it works. Thanks!
    – Dave Alger
    Mar 20 '12 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.