You need to sign in to do that
Don't have an account?
christwin123
Setting a Boolean value for a variable inside a Java Script in an Apex Page
Hi,
I want to set the value of a Rerender variable inside a Java script in an apex page. I give that as below bot it is not working right.
<script>
function earth(){
{!Homeselected} = False;
}
</script>
I call the function from an HTML Href Link.
<li><a href=\'/apex/Home?isdtp=vw\' target=\'iframe_a\' onclick="return earth();">Home</a></li>
But I am not able to set that variable.Could someone please guide me in setting the value.
Thanks in Advance.
Christwin
Use apex:actionFunction. Insert the following code inside an apex:form element anywhere in your VF page.
Now you will be able to set the value from JavaScript, like this,
Things to note:
1. You must have public setter method defined in your constructor, like this:
2. Call to setHomeSelected from JavaScript is asynchronous. So if you need any JavaScript operation after this call you have to use callback mechanism. Like this,
Now if you have a JavaScript method defined, it will be called once the setter of HomeSelected returns.
3. Rerender attribute in actionfunction declaration signifies that it is one Ajax request and the associated component will get rerendered after completion of the call. If you don't use this attribute, it will be one post request and your page will get refreshed. I have used rerender="none". This one I use when I need to do asynchronous request and I don't have anything to rerender. This will work normally provided you don't have any component with ID "none". If you have one, please use something else instead of none.
All Answers
Use apex:actionFunction. Insert the following code inside an apex:form element anywhere in your VF page.
Now you will be able to set the value from JavaScript, like this,
Things to note:
1. You must have public setter method defined in your constructor, like this:
2. Call to setHomeSelected from JavaScript is asynchronous. So if you need any JavaScript operation after this call you have to use callback mechanism. Like this,
Now if you have a JavaScript method defined, it will be called once the setter of HomeSelected returns.
3. Rerender attribute in actionfunction declaration signifies that it is one Ajax request and the associated component will get rerendered after completion of the call. If you don't use this attribute, it will be one post request and your page will get refreshed. I have used rerender="none". This one I use when I need to do asynchronous request and I don't have anything to rerender. This will work normally provided you don't have any component with ID "none". If you have one, please use something else instead of none.
Thank you so much Akram.
Ill try this and let you when happened soon.
Regards,
Christwin
It Worked!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thanks,
Christwin