I have a little challenge which I'm trying, I want whenever the checkbox is checked I want to copy the values into input text fields in visualforce page.

So here I have multiple rows and corresponding to that I have checkboxes, Whenever I click a checkbox values should pass to input text fields.

For more understanding, I'm attaching the screenshot of challenge.

enter image description here


 <apex:pageBlockTable value="{!WrapperOrder}" onclick="insert_numbers()" var="or" id="pbtable">    
<apex:column headervalue="Batch Price and Quantity">
                         <apex:pageBlockTable value="{!or.batc}" var="ba" id="thispa">  
                             <apex:column headerValue="Price">
                                <apex:outputtext value="{!ba.Unit_Price__c}" />
                             <apex:column headerValue="Qty">
                                <apex:outputfield value="{!ba.Asked_Qty__c}" />
                             <apex:column headerValue="Action" id="thiscol" >
                                <apex:inputCheckbox value="{!or.checkval}" >
                                <apex:actionSupport event="onclick" action="{!copyField}" reRender="pbtable" /> </apex:inputCheckbox><!-- pageblocktable Id is rendering -->
                 <apex:column headerValue="Unit Price"  >
                     <apex:inputField id="rpri" value="{!or.rorli.Price__c}" Style="width:50px" styleClass="spri" />
                 <apex:column headerValue="Qty" id="col" styleClass="col" >
                     <apex:inputField id="rqty" value="{!or.rorli.Quantity__c}" Style="width:25px" styleClass="sqty" />

Apex code of that function:

public void copyField(){

             List<batch__c> batcj1=new list<batch__c>();


             for(WrapperOrderline wraporderObj :WrapperOrder) {

                    System.debug('Entered to the loop');
                    Map<string,List<batch__c>> mapq=new Map<string,List<batch__c>>();
            // if(!mapq.containsKey(wraporderobj.rorli.Name)){              
               if(wraporderObj.checkval==true) {

                    wraporderObj .rorli.Price__c=wraporderObj.batc[1].Unit_Price__c;
                    String qtyc=wraporderObj.batc[1].Asked_Qty__c;
                    wraporderObj .rorli.Quantity__c=Integer.ValueOf(qtyc);
                    wraporderObj .rorli.Price__c=null;
                    wraporderObj .rorli.Quantity__c=null;
                    System.debug('not selected true');


Now what is happening with that code is whenever I true the checkbox it's not happening(means it's checking to the true state). When I check last checkbox in the row that will check all boxs to true and it will copy the data which is there in the memory location 1 of one in the list of the map. Here I want o know where I'm wrong, to get the proper result.

  • Instead of posting duplicate questions, please edit your existing post to add the details that were requested by community members. – David Reed Apr 29 '19 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.