1

I created a custom lookup (user) field and then added it to my Visualforce page

<tr><td style="text-align:center;"><b>Engineer Assigned</b> </td></tr>
         <tr><td><apex:inputField value="{!objRD.Assigned_To__c}" rendered="{!IsEdit}"/></td></tr><br/>
         <tr><td><apex:outputField value="{!objRD.Assigned_To__c}" rendered="{!!IsEdit}"/></td></tr><br/>

the output looks like this:
enter image description here

However, I don't want the drop down box to be displayed.

Looking at the generated HTML, the ID is different for multiple instances.

<select name="j_id0:j_id2:j_id12_mlktp" title="Search scope" id="j_id0:j_id2:j_id12_mlktp" onchange="LookupAutoCompleteInputElement.handleLookupTypeChange('j_id0:j_id2:j_id12',false);">

or

<select name="j_id0:j_id21:j_id31_mlktp" title="Search scope" id="j_id0:j_id21:j_id31_mlktp" onchange="LookupAutoCompleteInputElement.handleLookupTypeChange('j_id0:j_id21:j_id31',false);"><option selected="selected" value="005">User</option>

Is there a way either using CSS or Javascript to hide all of the controls that end with _mlktp.

Any other option is greatly appreciated.

//What I have tried so far: 1. Add a style tag to visual force and set it to hide 2. Look online for options, and will continue until I find a solution.

4 Answers 4

5

I was able to find the solution on this site: http://www.thephani.com/hide-user-dropdown-on-lookup-visualforce/

The trick in here is to hide the select generated by html altogether. This is done by css by setting the inputfield's select visibility as hidden.

<apex:inputField styleClass="hideDropdown" value="{!Account.OwnerId}"/>

<style>  
    .hideDropdown select{
        visibility: hidden !important;
        display: block !important;
    }
</style>

Hopefully this will help someone else.

2
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
    – Saroj Bera
    Jul 16, 2015 at 4:06
  • This was very helpful. However, the form put the input field on the next row down instead of right next to the label. I wanted the field to be right next to the label. So, I changed "display: block" to "display: none". That might be of some help to others looking for a similar solution.
    – smckitrick
    Nov 18, 2015 at 17:34
0

I believe this can be solved by using the <apex:pageBlockSectionItem> in conjunction with your <apex:inputField> and a new <apex:outputLabel>.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_pageBlockSectionItem.htm

2
  • Hello, I am not sure I understand your answer. Could you please try to describe it in a different way.
    – MicroSumol
    Jul 16, 2015 at 1:12
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
    – Saroj Bera
    Jul 16, 2015 at 4:06
0

Use this script:

var j$ = jQuery.noConflict();

j$(document).ready(function(){
  j$("[id$=mlktp]").hide();
});  
-1

I'm pretty sure you can just add html-hidden="hidden" to the tag and it will work.

If not you can also use:

<apex:inputHidden value="{!inputValue}" id="theHiddenInput"/>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .