Note that there are some explanatory texts on larger screens.

plurals
  1. POGet id of SharePoint formfield for jQuery
    primarykey
    data
    text
    <p>I have a script I wrote to toggle some SharePoint formfields. I've gotten them to hide when the page loads, but I am unable to get them to show because I don't know how to pin down what the ids of the formfield controls are going to be. </p> <p>I had thought about adding an id to the Request Type row, but I doubt that would do any good as it's the control itself, and not the <code>tr</code> that it occupies that changes. Any suggestions?</p> <p>Actually, if I could figure out a way to get the fieldname attribute of the <code>SharePoint:FormField</code>, that would be my preferred method.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("tr.anon").hide(); $("tr.reqDet").hide(); $("#ff5{$Pos}").change(function(){ $(".anon").toggle(); }); $("#ff3{$Pos}").change(function(){ $("#ff4{$Pos}").toggle(); }); }); &lt;/script&gt; &lt;tr&gt; &lt;td width="190px" valign="top" class="ms-formlabel"&gt; &lt;H3 class="ms-standardheader"&gt; &lt;nobr&gt;Request Type&lt;span class="ms-formvalidation"&gt; *&lt;/span&gt;&lt;/nobr&gt; &lt;/H3&gt; &lt;/td&gt; &lt;td width="400px" valign="top" class="ms-formbody"&gt; &lt;SharePoint:FormField runat="server" id="ff3{$Pos}" ControlMode="New" FieldName="requestType" __designer:bind="{ddwrt:DataBind('i',concat('ff3',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@requestType')}"/&gt; &lt;SharePoint:FieldDescription runat="server" id="ff3description{$Pos}" FieldName="requestType" ControlMode="New"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="reqDet"&gt; &lt;td width="190px" valign="top" class="ms-formlabel"&gt; &lt;H3 class="ms-standardheader"&gt; &lt;nobr&gt;Request Details&lt;/nobr&gt; &lt;/H3&gt; &lt;/td&gt; &lt;td width="400px" valign="top" class="ms-formbody"&gt; &lt;SharePoint:FormField runat="server" id="ff4{$Pos}" ControlMode="New" FieldName="requestDetails" __designer:bind="{ddwrt:DataBind('i',concat('ff4',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@requestDetails')}"/&gt; &lt;SharePoint:FieldDescription runat="server" id="ff4description{$Pos}" FieldName="requestDetails" ControlMode="New"/&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Many thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload