SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a textfield in sharepoint list form and I want to set the value using jquery or javascript below is the tag:

<asp:TextBox runat="server" id="ff47{$Pos}" text="{@Name}" __designer:bind="{ddwrt:DataBind('i',concat('ff47',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Name')}" />

I am using this to set var ele = $("input[title='Name']").val("Bob"); but it is not setting the value, any suggestions?

share|improve this question
This guy wants to set or hardcode a value in a formfield in sharepoint. More clear than water. Does anyone have a solution about this? Regards Pete – user20979 Nov 22 '13 at 19:37

you might added the extra curly brace to build the MAIN() like the sample below

<script type="text/javascript">
    $(document).ready(function () {

        //program logic


           } // the culprit extra brace


Hope it helps.

share|improve this answer

You need to Inspect that particular textbox with FireBug or IE Developer tools. If I am right the asp:Textbox is internally converted to an input control which will have a unique attibute. You can use this attribute to pickup the input with JavaScript/jQuery and set the value.

From what I can gather, you are setting the id and the text dynamically by using placeholder variables. I would inspect these two attributes and reference the input field by using one of them.

share|improve this answer
As you could see, his jquery has input in the selector – Colin Feb 2 '12 at 23:59
True. But the attributes of the input are being generated dynamically and they need to be picked up correctly with jQuery. – Vardhaman Deshpande Feb 3 '12 at 0:58

Could you post the exact rendered Html? I ask this because usually id and name attribute value contain a crappy generated string. You could try a wildcard in your selector:

var ele = $("input[title='*Name']").val("Bob"); // notice the *
share|improve this answer

Try this instead:

share|improve this answer
Hi James,i tried it but it is not working – spStacker Feb 2 '12 at 21:14

I really wished to understand what has been asked in this question.
Having too long for a comment misunderstandings I hope the question would be reformulated into more comprehensible one...

The markup of an element (or node but not "tag") does not look to me as part of list form (are there forms for a list at all?) but rather of item form.

The jQuery expression:


sets the known value "Bob" to Sharepoint field of node with attribute 'Title="Name"', while the expression:

var ele = $("input[title='Name']").val();

gets that value into variable ele.
One more problem is that cited element doesn't contain any attribute Title?!

So, it is not clear to me what, from where to where the questioner is asking to set or to get? and what?

share|improve this answer

Try this:
Using Sharepoint Designer 2010: modify form.
Wrap textbox by div with special ID.
Such as ID="myDiv"

This must help you to find needed textbox!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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