function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SF7SF7 

Hide InputText Field in Vf page

hi,

 

i had a visual force page with dependencies on it  and in my vf page  i had a input filed which should not appear and i cant delete that field as it is controlling the dependecies can i just hide that field and how can i do it.

 

this is my field code

<apex:inputField id="LOB" value="{!wrapper.ocr.Line_of_Business__c}" style="width:300px"/>

 

thanks

akhil 

Starz26Starz26

add rendered='FALSE' to the tag

SF7SF7

hi thanks for replying

 

and tried rendered tag it's even disabling the functionality

akhil

Ispita_NavatarIspita_Navatar

 

Hi,

  If you want to hide input field there are 2 ways to achieve this:-

  1. Place your input field in div and set visibility of the div to say display =none. Do refer to the snippet below for clarity

     <div style="display:none;">

     <apex:inputField id="LOB" value="{!wrapper.ocr.Line_of_Business__c}"     style="width:300px"/>

     </div>

2. Or use  <apex:inputHidden/>  instead of <apex:inputField/> and assign value in inputhidden field using javascript.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

SF7SF7

Hey, 

Thanks For Replying,

 

I tried the div tag and i still see the filed on the page

 

and i tried even using the apex:inputhidden tag but what happens is the field disappears and the dependecies are also gone

 

thanks 

Akhil

hemantgarghemantgarg

Try in following way :-

 

<apex:inputField id="F1" value="{!<Your variable name>}" />

<script>document.getElementById('{!$Component.F1}').style.display = 'none';</script>

 

I think it should work as I have tried it .

 

DRobi83DRobi83

I tried this and it worked with javascript, however the lavel and the lookup icon remain (only the field itself becomes hidden)

 

Any ideas how to get rid of the label/lookup icon?

hemantgarghemantgarg

Hi,

 

You have to hide them too using javascript like :-

 

for lookup icon :-

document.getElementById('{!$Component.F1}_lkwgt').style.display = 'none';

 

for label :-

document.getElementById('<id of label>').style.display = 'none';

 

you can inspect the dom id in firebug or any other means.

SFDC HedgehogSFDC Hedgehog
Just riffing on hemangarg's answer, you can just set the label=" "    attribut for the field.  There will be a blank line in the panel, but it's a lot easier than installing fiddler, firebug or any of that stuff.