Short version of the question: I am dynamically building the option list of a DropDownList based on a selection from another DropDownList with jQuery. How do I bind the new option list so that it will post back to the list?

Details: I'm using SP2010 and SharePoint Designer The new form is feeding an external list in an SQL db. A second external list is the dynamic list source.

The user is selecting a location which jQuery uses to create a list of names sourced from the 2nd external list. Unfortunately, the name selected is not being posted back. I can hard code the names from SP designer and that posts, but the list generated by jQuery is not posting. I assume this is because jQuery generates the list after ddwrt:databind is ran.

Thanks for the help. KR

1 Answer 1


In leu of the dynamic dropdown list not posting, here's the workaround with jquery. I'd still be interested in hearing a better way.

Instead of deleting the original FormField, I enclosed it in a span tag with style=display:none. Then using jquery I called the selected value and changed the value of the original FormField.

<td width="400px" valign="top" class="ms-formbody">
    <span id="originalFormField" style="display:none">
        <SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="Name" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string('')),'@Name')}"/>
    <span id="dropdownlist1">
        <SharePoint:DVDropDownList runat="server" id="ddl2{$Pos}">
                <asp:ListItem runat="server" value="0">Please select a name...</asp:ListItem>
    <SharePoint:FieldDescription runat="server" id="ff2description{$Pos}" FieldName="Name" ControlMode="New"/>

<script type="text/javascript" id="saveName">
        function saveName(){
            var idDDL2 = '#'+$("select[id*='ddl2']").attr("id");
            var idFF2 = '#'+ $("[id*='ff2']").attr("id");
                var value = $(idDDL2+' option:selected').text();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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