1

I have created a SPList named Pets having 2 fields petname[single line of text] and pettype[choice field] and created a new customform from this list using SP Designer 2010. Now I need to presaveaction and some jquery,spservices stuff in this form for validation and manipulation when save button is clicked. But I am not seeing any ID of the field for applying the jQuery and fetch the values.Am able to see the below code.

  • Can I create a separate ID/assign separate ID for each field in this form, just like we do in ASP.NET forms and visual web part using SP D?

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

    currently this is my spd form looks like, ie the code for petname field. am confused by id="ff2{$Pos}".

  • Can i use this in my jQuery/PreSaveAction validation as it is? If not, whats the best way of implementing this assignment of field IDs?
  • I have saved the form and form is appeared with these 2 fields. If I want to add 3rd column say a checkboxlist through SD P, how to achieve this?

    I tried adding a new row and on the 2nd column I tried to insert a control abd added the dvcheckboxlist, but this action failed and my form becomes corrupted / shows error when clicked on add new item.

  •              <tr>
                        <td width="190px" valign="top" class="ms-formlabel">
                            <H3 class="ms-standardheader">
                                <nobr>selections</nobr>
                            </H3>
                        </td>
                        <td width="400px" valign="top" class="ms-formbody">
                            <SharePoint:FormField runat="server" 
                   id="ff4{$Pos}" ControlMode="New" FieldName="selections" 
                         __designer:bind="
                    {ddwrt:DataBind('i',concat('ff4',$Pos),'Value',
                  'ValueChanged','ID',
             ddwrt:EscapeDelims(string(@ID)),'@selections')}"/>
                            <SharePoint:FieldDescription runat="server" 
                        id="ff4description{$Pos}" FieldName="selections" 
                       ControlMode="New"/>
                        </td>
                    </tr>                       
    

    here, I am having multiple checkboxes, but in my presaveaction, how can I get the each & every ID of the checkboxes, such that, i can get the status of each checkboxes when submit button is clicked!

    Below is my F12 Dev tools section of checkboxlist.Assuming that, i need to port this code from one list to new list or new env.,i cant enter the same ids [ here ctl00_m_g_baff0aa2_5fdf_420b_ab45_b8235b35dcd3_ff4_1_ctl00_ctl00 ] to the new list as list ids would br diffeent for different lists. So is there a way i can specify a ID like id=chkboxforORCEBE" in my designer form such that, my jQuery validation is smooth.

    ORCIBE

    1 Answer 1

    0

    If you're planning to use JQuery, you can access the document elements on the client side using [title] attributes. Basically, you need to view source and analyze how to select the elements in JQuery. You can't use the ID as it's set by the server side code.

    Here are few examples that might help:

    $("input[title='myTextField']").val("");
    $("select[title='MyChoiceField']").val("");
    $('nobr:contains("DBType")').closest('tr').hide();
    
    

    For JQuery selectors, visit this link

    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.