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
Deepak PansariDeepak Pansari 

How to update Textbox value on the fly without pressing any button on the VF page like java script.

Hi,
Can we update the value of text box field on the fly on any custom Visualforce page.
For example I have a form with two textbox   1. Prepaid voucher price 2. Talk time
When user put the value on prepaid voucher price 50 bucks then automatic in the Tal time field the value 20 buck will be populating.
 
I hope you understand my question
 
Please let me know if any one has any idea on Visualforce.
 
Thanks,
Deepak 

Best Answer chosen by Admin (Salesforce Developers) 
Venkat PolisettVenkat Polisett

<apex:page controller="TestPage"> <apex:form > <apex:pageBlock > <apex:outputPanel id="discount"> Enter Discount Code: <apex:inputText value="{!Code}" > <apex:actionSupport event="onblur" action="{!selectDiscount}" rerender="discount"/> </apex:inputText> <br/> Discount %: <apex:outputText value="{!Discount}"/> <br/> Credit card No: <apex:inputText value="{!Card}" /> </apex:outputPanel> </apex:pageBlock> </apex:form> </apex:page> public class TestPage { public Integer Discount {get; set;} public String Code {get; set;} public String Card {get; set;} public PageReference selectDiscount() { if (Code == 'A') Discount = 10; else if (code == 'B') Discount = 20; else Discount = 30; return null; } }

 

 

 

Next time, please read the docs. Do your part.

 

All Answers

BrianWKBrianWK

Deepak,

 

I do something similiar where a user provides input (in this casea  checkbox on a data table) and a separate area spits out data based on the selection.

 

I use a custom controller for mine since the output text is dependent on the values selected in the table.

 

I have an outputpanel containing the the an outputfield that is updated. On the Inputfield I have an apex function that calls me controller method (to determine what the outputfield value is) and then refreshes my Outputpanel ID.

 

Venkat PolisettVenkat Polisett

<apex:page controller="TestPage"> <apex:form > <apex:pageBlock > <apex:outputPanel id="discount"> Enter Discount Code: <apex:inputText value="{!Code}" > <apex:actionSupport event="onblur" action="{!selectDiscount}" rerender="discount"/> </apex:inputText> <br/> Discount %: <apex:outputText value="{!Discount}"/> <br/> Credit card No: <apex:inputText value="{!Card}" /> </apex:outputPanel> </apex:pageBlock> </apex:form> </apex:page> public class TestPage { public Integer Discount {get; set;} public String Code {get; set;} public String Card {get; set;} public PageReference selectDiscount() { if (Code == 'A') Discount = 10; else if (code == 'B') Discount = 20; else Discount = 30; return null; } }

 

 

 

Next time, please read the docs. Do your part.

 

This was selected as the best answer
Deepak PansariDeepak Pansari

Many Thanks!:smileyhappy:

 

I hope this will work for me.

 

-Deeapk