You need to sign in to do that
Don't have an account?
Clear inputtextarea value onclick event
Hi,
I have apex:inputtextarea field which has default inital value. Onclick event on this field it should get empty (blank). How could I acheive this?
Rahul
I have apex:inputtextarea field which has default inital value. Onclick event on this field it should get empty (blank). How could I acheive this?
<apex:inputTextarea rows="1" id="inputpa" value="{!ebrecs.Attendance_Notes__c}"/>Thanks,
Rahul
<!-- if you have jquery in static resource <apex:includescript value="{!URLFOR($Resource.jquery, 'jquery-1.10.2.min.js')}" /> -->
<apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"/>
<script>
var j$= jQuery.noConflict();
function clearMe(){
j$("[id$=inputpa]").val('');
}
</script>
<apex:form>
<apex:inputTextarea rows="1" id="inputpa" value="{!ebrecs.Attendance_Notes__c}" onclick="clearMe();" />
</apex:form>
</apex:page>
All Answers
<!-- if you have jquery in static resource <apex:includescript value="{!URLFOR($Resource.jquery, 'jquery-1.10.2.min.js')}" /> -->
<apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"/>
<script>
var j$= jQuery.noConflict();
function clearMe(){
j$("[id$=inputpa]").val('');
}
</script>
<apex:form>
<apex:inputTextarea rows="1" id="inputpa" value="{!ebrecs.Attendance_Notes__c}" onclick="clearMe();" />
</apex:form>
</apex:page>
You may use either actionSupport or actionFunction. actionFunction example is given below.
e.g.
<script type="text/javascript">
function clearTextJS()
{
clearTextAF();
}
</script>
<apex:page>...
<apex:actionFunction name="clearTextAF" action="{!clearText}" immediate="true"/>
<apex:inputTextarea rows="1" id="inputpa" value="{!ebrecs.Attendance_Notes__c}" onclick="clearTextJS();"/>
Define method clearText() in Controller/Extension. You may either use rerender with actionFunction or return a PageReference from the method clearText().
---------------------------------
If this resolves your issue, please mark the question as Resolved.