1
votes

I am using javascript on my visualforce page in Salesforce. I was trying to find some documentation on what can be done to visualforce's native <apex> tag attributes.

What I specifically am trying to do is clear an input text box (my search field) when the user clicks on it. Currently it is populated with the current query results, which is how I want it, but I was trying to add some detail and have it auto-clear when the user selects the text box to enter a new search query.

This is the javascript function I'm using to change the value of the input text box. The id of the search field on the visualforce is search and it is in the navForm (I am certain the component is being found correctly and I have tested with an alert that the function is being called).

<script type="text/javascript">
function clearField() {
    var searchField = document.getElementById('{!$Component.navForm.search}');
    searchfield.value = '';
}

'value' is the name of the input text attribute that is used to fill the textbox of the current query correctly when the page loads. The other attributes for that visualforce page component (title, label) are not what I need.

1

1 Answers

0
votes

There is nothing special for Visualforce in Javascript. Visualforce markup will be transformed in HTML. So, you need to write your Javascript code thinking about "HTML version" of your page. Before coding JS I open my page in FF with Firebug.