You need to sign in to do that
Don't have an account?
lapaul
How to create a popup window using Apex code
Hi,
How do you create/display a small popup windows right in the middle just to inform the users some information and when a user click Ok the popup window will go away? Please advice. Please send sample codes if available.
thanks
Paul
I'm not sure about Apex, but I know it's possible with Javascript, which visualforce supports. When do you want the pop-up to occur?
You might try doing a quick google search for javascript notifications.
I found the Javascript below that works fine now. However how do you apply the following command in Visualforce? Basically I want if the criteria is evaluated to true it then will display it otherwise it wil not.
Response.Write("<script language="JavaScript"> { var x = confirm ('Congratulation! '); } </script>")
Please advice. thanks
You'll need to write the condition such that the VF criteria is understood by the JavaScript, e.g.
In this case the
gets turned into "yes" by the time the page is rendered, thus the JavaScript condition evaluates to true and the confirmation dialog is displayed.
As you need to alert a popup window with confirmation message.
You can try this
<script language="JavaScript">
confirm('{!IF(controllerVariable == 'yes', 'Confirmation', 'anyothermessage')}');
</script>
This will prompt irrespective of whether the condition is true or false
or
<script language="JavaScript">
if('{!controllerVariable}' == 'yes')
alert('Confirmation');
</script>
This will prompt only if variable in controller has the value 'yes'
controllerVariable is a variable defined in Apex controller.
I feel the second approach will be better for you.
Thanks for all your tips.
Did you finally got the popup window working now?
Yes the popup window works now. Thanks.
Hi, could you tell me how you did this? I'm trying to do the same thing using a scheduled class. So far I have something like:
But I know the second method is wrong. :(
I'm afraid you won't be able to do this from a scheduled class, for the simple reason that there is no browser-based user request associated with it.
The scheduled job runs on the Force.com server at a particular time, thus there is no user to return any information to.
Are you trying to send some information about the scheduled job to a user? If that is the case, I'd suggest a notification email.
No I was trying to pop up a custom notification about tasks, but what you said makes sense. I kind of figured it would be something like that. Thanks for the confirmation!
I'm trying to craete a popup where users can input or chosse numbers from 1-10 (Kind of picklist selection) Please suggest. Thanks