function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Harshada Kadu 9Harshada Kadu 9 

how to set value of input field when checkbox is checked using javascript in visualforce page

<apex:page standardController="Event_Detail__c" extensions="addProduct">
<script type="text/javascript">     
     function selectAllCheckboxes(obj,receivedInputID){
                var inputCheckBox = document.getElementsByTagName("input");
                for(var i=0; i<inputCheckBox.length; i++){
                    if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                        inputCheckBox[i].checked = obj.checked;
                    }
                }
     }    
    
    
</script>

  <apex:pageMessages />
  <apex:form >
      <apex:pageBlock >
           <apex:pageBlockButtons >      
           <apex:commandButton value="Save & New" action="{!saveAndNew}"/>          
                <apex:commandButton value="Done" action="{!save}" />
                <apex:commandButton value="Cancel" action="{!back}" />           
           </apex:pageBlockButtons>
           
         <apex:pageBlockSection >
           <apex:pageBlockSectionItem >Person Name:
                 <apex:inputField value="{!e.Person_Name__c}"/></apex:pageBlockSectionItem>
           </apex:pageBlockSection>
           
           <apex:pageBlockSection title="All Products" columns="1">    
                <apex:pageBlockTable value="{!wrappers}" var="c">
                        <apex:column >
                            <apex:facet name="header">
                                <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                            </apex:facet>
                            <apex:inputCheckbox value="{!c.checked}" id="inputId"/>                   
                        </apex:column>
                        <apex:column value="{!c.transferProduct.Product_Name__c}" headerValue="Product Name"/>  
                        <apex:column headerValue="Unit Price">
                            <apex:outputText value="{!c.transferProduct.Unit_Price__c}" />
                        </apex:column> 
                        <apex:column headerValue="Quantity" >
                              <apex:inputField value="{!c.event.Quantity__c}" />
                        </apex:column>                                                               
                </apex:pageBlockTable>
            </apex:pageBlockSection>
         </apex:pageBlock>
  </apex:form>    

</apex:page>
David HalesDavid Hales
Hi ,

Can you please let me know what error are you facing ?

Best Regards 
David Hales (1044)
PawanKumarPawanKumar
Hi Harshada,

Please look into below link for better understanding.

https://developer.salesforce.com/forums/?id=906F0000000BRNuIAO

Regards,
Pawan Kumar

PS: Please let me know if it helps you.
Harshada Kadu 9Harshada Kadu 9
Hi David, Thankyou but I got the solution. Regards, Harshada Kadu
Harshada Kadu 9Harshada Kadu 9
Hi PawanKumar, Thanks for the link. I got the solution.Thanks for the help. Regards, Harshada
PawanKumarPawanKumar
Hi Harshada,
It's really great to  know. Please mark it solved as well.

Regards,
Pawan Kumar