In this visualforce page there are two inputs and one button. How to swap the values in given two inputs from input-1 to input-2 and input-2 to input-1. Please provide suggestions
I tried the above code
VF code:-
<apex:page controller="Swap_Values">
<apex:form >
<apex:outputLabel >Enter Value</apex:outputLabel>
<apex:inputText value="{!x}"/>
<apex:inputText value="{!y}"/>
<apex:commandButton value="Swap" action="{!SV}"/>
</apex:form>
</apex:page>
Apex code:-
public class Swap_Values {
public String y { get; set; }
public String x { get; set; }
public PageReference SV() {
x=y;
y=x;
return null;
}
}
Please provide suggestions to do this swap functionality