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
puli rajupuli raju 

copy field 1value to field 2 on button click

DeepthiDeepthi (Salesforce Developers) 

Use <apex:actionSupport> to meet this requirement. Please check the below code.
<!--- Visualforce Page ----->
<apex:page controller="ControllerCopyValueButton">
<apex:form id="a">
    <apex:outputLabel >First Name</apex:outputLabel>
    <apex:inputText value="{!fn}"/> 
    <apex:commandButton value="Copy Field" action="{!copyField}"/><br/>
    <apex:outputLabel >Last Name</apex:outputLabel>
    <apex:inputText value="{!ln}">
        <apex:actionSupport event="onclick" reRender="a"/>
public class ControllerCopyValueButton {
     public String fn {get;set;}
     public String ln {get;set;}
     public PageReference copyField{get; set;}
     public PageReference copyField(){
        if(fn!='' || fn!=null){
        ln = fn;
        return null;

Hope this helps you!
Best Regards,