You need to sign in to do that
Don't have an account?

copy input field data into another input field
So i found a similar message here hat gave some insight into how to copy text from my venue address fields to my vendor address fields. The code shown was just JS and im using apex so getting i to work has my brain spinning. So atached is my controller code and the vf code. I have tried actionsupport functions, onlick, action region and rendered but notihng seems to pass any data. I took the rendered out becasue it gave me a save error about type not matching.
Can anyone see what im going wrong:
My Controller code: public PageReference getsameAddress (){ if (this.request.Same_as_Venue__c == true) { this.request.Venue_Address__c = this.request.Company_Address__c; this.request.Venue_City__c = this.request.Company_City__c; this.request.Venue_Postal__c = this.request.Company_Postal__c; this.request.Venue_Country__c = this.request.Company_Country__c; this.request.Venue_State__c = this.request.Company_State__c; } return null; }
My vf code: <!-- Vendor Info --> <!-- Only displayed for internal users --> <apex:pageBlockSection title="Vendor Details" rendered="{!isInternal}" columns="1" id="vendorinfo"> <apex:pageBlockSectionItem > <apex:actionregion > <apex:outputLabel >Same as Venue Details</apex:outputLabel> <apex:inputField value="{!request.Same_as_Venue__c}"> <apex:actionSupport event="onclick" /> </apex:inputField> </apex:actionregion> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel >Phone</apex:outputLabel> <apex:inputField value="{!request.Company_Phone__c}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel >Address</apex:outputLabel> <apex:inputField required="true" value="{!request.Company_Address__c}" styleClass="longinput"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel >City</apex:outputLabel> <apex:inputField required="true" value="{!request.Company_City__c}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel >Postal Code</apex:outputLabel> <apex:inputField required="true" value="{!request.Company_Postal__c}"/> </apex:pageBlockSectionItem> <!-- This is a little complex... The action region allows the page to only submit this specific field to the controller when calling AJAX functionality. Without the action region, required fields cause the rerender action to fail. --> <apex:pageBlockSectionItem > <apex:outputLabel >Country</apex:outputLabel> <apex:actionRegion > <apex:inputField required="true" value="{!request.Company_Country__c}"> <apex:actionSupport event="onchange" reRender="vendorstate"/> </apex:inputField> </apex:actionRegion> </apex:pageBlockSectionItem> </apex:pageBlockSection>
I don't surely understand from which field to which you want to copy, but it can be done using javascript.
Can you share more info about the req? Exactly which field to copy to where?
Thanks
You were so close man!
You missed the controller call from the action support
Thanks Avidev9, however now im getting the "must enter value" error on my req fields. Im wondering if i can have more than one actionregion tag in the text.
And the fields i am trying to push are:
Venue Address into Company Address field
Venue City into Company City
Venue Postal into Company Postal
Venue Country into Company Country (this is a picklist)
Venue State into Company State (this is a picklist)
Im doing this in the controller. Here is the vf code for both sections:
Just wrap the inputField with action Region
Still getting the "must enter value" error message. Plus i dont see any data being pushed into the fields
So it looks like your update has me creating a new pageblocksection just around the fields i am pushing data into is that correct.
Meaning:
1. Same as venue checkbox should be its own pageblocksection
2. Address / City / State / etc should have their own page block section
See mocked code attached.
OK so i've changed the code to be a simple click command link to pass data. My renders and action regions are working fine. But there is no data being passed. I realized that i had the field backwards in my controller and fixed that but still nothing. So below you will see i put a value in one of the fields and when the function is called it shows up in the field. So hopefully someone will see what im missing on why the field from the form is not being passed into the field i want. Im wondering is i need sometihng else in my pagereference to pull and store the data from the current form and then push into the fields i want...
so right now the company address field is reading what i have. So i know the call and action is working...