Link to home
Start Free TrialLog in
Avatar of Seven0fNine
Seven0fNine

asked on

Hiding SharePoint URL field (spfieldURL) using jquery

I am having trouble hiding a SharePoint URL field on an EditForm.aspx.


Client Link   Type the Web address: (Click here to test)
                                     [____________________________]

Type the description: [____________________________]

 

I can hide other controls such as Date picker, People picker, drop-down and single text fields using jquery:

        $('td.ms-formlabel:contains("Start Date")').parent().hide();
      $('td.ms-formlabel:contains("TaskName")').parent().hide();
      $('td.ms-formlabel:contains("Status")').parent().hide();
     
However, this code does not hide the URL field:

        $('td.ms-formlabel:contains("ClientURL")').parent().hide();


Appreciate it if someone could help,

Thank you
Avatar of leakim971
leakim971
Flag of Guadeloupe image

you need to get the right selector
for that, with Chrome for example, right click on the field itself, choose inspect
now on the left panel, your field should be selected, maybe you need to click on its parent to get the exact container you want to hide. you need a unique selector too else you can hide the wrong one
if you need more help, right click on a parent, click copy, copy outerhtml and paste it here
Avatar of Seven0fNine
Seven0fNine

ASKER

Thanks for your reply: I have selected the whole object - the field reference I am using is the FieldInternalName, I cannot see any other references... other than the Input type IDs..



User generated image

so the jquery that is not working is using $('td.ms-formlabel:contains("DeskSite_x0020_Folder_x0020_ Link")').parent().hide(); 
no, what you're showing is acommented HTML, it CAN'T be that
it's just before
if you can't locate it, right click the the full table anc copy/paste the table outerHTML here
your screenshots doesn't help, it just show your interpretation
Below is the outerHTML <tr> section where the SP URL control is contained:

<tr>
      <td nowrap="true" valign="top" width="113px" class="ms-formlabel"><span class="ms-h3 ms-standardheader">
      <nobr>Desksite Folder Link</nobr>
   </span></td>
      <td valign="top" width="350px" class="ms-formbody">
      <!-- FieldName="Desksite Folder Link"
          FieldInternalName="Desksite_x0020_Folder_x0020_Link"
          FieldType="SPFieldURL"
        -->
         <span dir="none"><span class="ms-formdescription">Type the Web address:&nbsp;(<a id="Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_$UrlControlId" href="javascript:TestURL('Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_$UrlFieldUrl')" target="_self">Click here to test</a>)<br></span><input dir="ltr" type="text" value="http://Redirect.aspx?FID=2388721" id="Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_$UrlFieldUrl" title="Desksite Folder Link" class="ms-long" style="ime-mode : "><br><span class="ms-formdescription">Type the description:&nbsp;<br></span><input type="text" maxlength="255" id="Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_$UrlFieldDescription" title="Description" value="Open Client page" class="ms-long"><br></span>
       
       </td>
   </tr>
do you see the field/element you want to hide here : https://jsfiddle.net/df9swp83/ 

I can see the individual IDs of the input controls, but nothing else referring to 'entire' control (both fields are part of the SPfieldURL control)

 id="Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_$UrlFieldUrl"  id="Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_$UrlFieldDescription"

After some further reading - using SharePoint's 'internal field ID' to hide a control of this type may not be possible, so will likely come down to hiding the 'individual' input fields. Unless there is another way to hide the whole control?
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help :-)
you're welcome!