You need to sign in to do that
Don't have an account?
howto clear the pageBlockSection inputFields in visual force
Hi All,
In my aplliction is having 6 pageBlockSections.Each section is having 8 fileds.
I am facing the problem while clearing the fileds.If the fileds are not under pageBlockSection i can clear the fileds by using java script.
ex:
<script>
function clearflds()
{
document.getElementById('{!$Component.frm.details}').value=null;
}
</script>
<apex:inputField id="details" value="{!Sea_Foot_Note__c.Issue_Details__c}"/>
<apex:commandButton value="Cancel" onclick="clearflds()" />
But here i am facing the problem how to clear the pageBlockSection inputFields.
Ex:
One Section is having 4 fileds.They are one TextArea Field(Issue Details),2 Picklist Fields(Any issues,Clearing Category),and one Date Field(Control Date).By clicking on the New Button i can enter the values.By clicking on the save button i can save the record.By clicking on the cancel button i was unable to clear the fields.
My requirement is when i click on the cancel button i have to clear the values of 4 input fileds.These 4 fileds are under pageBlockSection.
Plz tell me if any one knows.
My sample code is as follows:
<apex:page standardController="Sea_Foot_Note__c" >
<apex:form id="frm" >
<apex:pageBlock>
<apex:pageBlockSection columns="2" showHeader="true" title="SFN Main Entity">
<apex:inputField id="issue" value="{!Sea_Foot_Note__c.Any_Issues__c}"/>
<apex:inputField id="details" value="{!Sea_Foot_Note__c.Issue_Details__c}"/>
<apex:inputField id="cdate" value="{!Sea_Foot_Note__c.Control_Date__c}"/>
<apex:inputField id="category" value="{!Sea_Foot_Note__c.Clearing_Category__c}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons>
<apex:commandButton value="New"/>
<apex:commandButton value="Cancel" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks in advance,
Manu..
Thanks for ur reply,
I have one more issue.If i click on Ok button it will goes to home page by using page redirection.But at the time i want save the record also.i am using like this.
controller code:
public PageReference hmpgmove()
{
PageReference pr =new PageReference('https://ap1.salesforce.com/home/home.jsp'); // or 'new PageReference('url');//
pr.setRedirect(true);
return pr;
}
Vf page code:
<apex:commandButton value="OK" action="{!save}" onclick="hmpgmove()"/>
But only one function is working.
Plz tell how to do saving the record as well as rediercting the home page with example.
Thanks in advance,
Manu..
Thanks for ur support,
In first issue i dont want to page redirect by clicking on the cancel button.If i click on the cancel button all fileds should be clear in the same page itself.
I used reRender tag also but it is not working.
<script>
function clearflds()
{
document.getElementById('{!$Component.frm.issue}').value=null;
}
</script>
<apex:pageBlock id="pg1" >
<apex:commandButton value="Cancel" oncomplete="clearflds()" reRender="pg1"/>
In the second issue when i click on the ok button i want save the record as well as redirect the page to Home tab.
plz help me.
Thanks in advance,
Manu..
try like this :
public PageReference save()
{
update yourobject;
else
insert yourobject;
PageReference pr =new PageReference('https://ap1.salesforce.com/home/home.jsp'); // or 'new PageReference('url');//
pr.setRedirect(true);
return pr;
}
Thanks for immediate reply,
I can able to save the record and redirect the page to home tab.But i was unable to clear the pageBlockSection fields with out page redirection.I have to clear the fileds with in the page itself.Plz give me the example.
Thanks in advance,
Manu..
sry ny friend ,this cannot be done for inputfields which are in pageblocktable also my friend