You need to sign in to do that
Don't have an account?
NehaKS
How to get apex page message in javascript
<apex:page standardController="Account"> <script type="text/javascript"> function test() { var accname=document.getElementById("{!$Component.f.pb1.pbs1.a}").value; alert(accname); var message=document.getElementById("{!$Component.f.pb1.msg}").value; alert(message); } </script> <apex:form id="f"> <apex:pageBlock id="pb1"> <apex:pageMessages id="msg" /> <apex:pageBlockSection id="pbs1"> <apex:inputField value="{!account.name}" id="a" /> <apex:inputField value="{!account.industry}"/> <apex:commandButton action="{!save}" value="Save!"/> <apex:commandButton onclick="test();" value="test"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
For the above code
I am getting the value of field in account name but i am not able to get the error message displayed in alert
Its giving as "undefined".
Could anyone please help me out with this.
pageMessages is not a web form element (i.e. button, textbox) so it does not have "value" (undefined).
try
document.getElementById("{!$Component.f.pb1.msg}").textContent;
or
document.getElementById("{!$Component.f.pb1.msg}").innerText;
whichever works.
All Answers
pageMessages is not a web form element (i.e. button, textbox) so it does not have "value" (undefined).
try
document.getElementById("{!$Component.f.pb1.msg}").textContent;
or
document.getElementById("{!$Component.f.pb1.msg}").innerText;
whichever works.
This worked. Thanks a lot :)
What if i want to get the value of a column in pageblock table using javascript. Is it possible using the value attribute.
I used the .value function but it returns nothing not even null.
Could you help me out with this issue please
Apex Class:-
Refer this code:
I want to display the column value...the focus should be on the row selected
Please help ..Its on urgent basis