Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8154463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:21:39+00:00 2026-06-06T16:21:39+00:00

Once a lookup field is populated and I open the same visualforce page later

  • 0

Once a lookup field is populated and I open the same visualforce page later then the lookup field is prepopulated.

I want to put ‘X’ next to Lookup field so that when ‘X’ is clicked, the field value gets cleared.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:21:41+00:00Added an answer on June 6, 2026 at 4:21 pm

    You can do this with a simple bit of javascript which sets the value of the field to blank, there’s just a bit of Force.com magic regarding obtaining the ID of the element to use. Below is a complete page which does what you need.

    <apex:page standardController="Contact">
        <apex:form >
            <apex:inputField id="accountLookup" value="{!Contact.AccountId}"/>
            <a href="#" onClick="document.getElementById('{!$Component.accountLookup}').value = ''; return false;">Clear</a>
            <apex:commandButton action="{!Save}" value="Save"/>
        </apex:form>
    </apex:page>
    

    Note that the recommended way of applying javascript to a link is to do it on page load, though you may find it simpler to do the above since it saves you having to drill down to the element {!$Component.Parent.Child.Grandchild} (which is needed when using <apex:pageBlock> etc.) and if javascript isn’t enabled, your user will have bigger problems than your link not working!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Once I've mapped my domain in NHibernate, how can I reverse lookup those mappings
I am developing an app that utilizes very large lookup tables to speed up
I want to create a temporary cache lookup to speed up a file lookup
I made a PHP page that looks up Constant Contact e-mail addresses in a
I'm building a Web Page that allows the user to pick a color and
I have an Access table that has a hyperlink field, with the records being
I have a Microsoft Access Popup Form which I use to lookup addresses. Once
I am working on a page that has a dynamically generated markup. And as
Once a user hits a URL the local machine does a lookup on the
i have an ip-to-country lookup table. this table is updated max once a month

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.