You need to sign in to do that
Don't have an account?
Deepak 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
<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
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.
<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.
Many Thanks!:smileyhappy:
I hope this will work for me.
-Deeapk