You need to sign in to do that
Don't have an account?
Harshada 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>
<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>
Can you please let me know what error are you facing ?
Best Regards
David Hales (1044)
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.
It's really great to know. Please mark it solved as well.
Regards,
Pawan Kumar