Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » Dynamic action 'Confirm' problem (apex 4.0.2)
Dynamic action 'Confirm' problem [message #535243] Tue, 13 December 2011 02:36 Go to next message
balckbandit5
Messages: 104
Registered: December 2011
Senior Member
Hello Smile

I'm having a problem with a dynamic action that is supposed to fire when a button is clicked.
I have tried 2 ways with different outcomes neither of which quite what I want:
First I tried having 'Confirm' as the action and then 'before page submit' as the trigger. And this worked properly, the confirmation message popped up and if I clicked cancel it stopped and if I clicked ok it submitted. BUT the problem was it fired on all the buttons that submitted the page, and I only wanted it on the 1 (CONFIRM)
So then I looked up how to trigger a dynamic action from a button and I did actually find this:
http://www.talkapex.com/2010/12/apex-how-to-trigger-dynamic-action-from.html
But it doesn't seem to work 100%, It does trigger the confirm box on only the 1 button but the problem is even if I press cancel it still submits the page.

So what I'm asking is: Is there a way to do this effectively with dynamic actions? If not presumably theres another way? (I think you can do it with javascript but I don't know javascript at all really so if thats the only way an example would be much appreciated)

Thanks Smile
Re: Dynamic action 'Confirm' problem [message #535258 is a reply to message #535243] Tue, 13 December 2011 04:22 Go to previous messageGo to next message
c_stenersen
Messages: 255
Registered: August 2007
Senior Member
In the button details under "button attributes" you can add onclick="javascript:confirm('mytext here')"
Re: Dynamic action 'Confirm' problem [message #535265 is a reply to message #535258] Tue, 13 December 2011 05:15 Go to previous messageGo to next message
balckbandit5
Messages: 104
Registered: December 2011
Senior Member
Do I need to edit any other settings? doesn't seem to work, nothing pops up
(I just copied and pasted onclick="javascript:confirm('mytext here')" do I need to change that at all?)
Re: Dynamic action 'Confirm' problem [message #535293 is a reply to message #535265] Tue, 13 December 2011 06:53 Go to previous messageGo to next message
c_stenersen
Messages: 255
Registered: August 2007
Senior Member
Ok, I see that now (I was sure that's how I had done it in the past, but obviously I was wrong.)

Try this then: In button action you choose redirect to URL. Then as the target you set:
javascript:if(confirm('My question here?')){
doSubmit('MYBUTTONNAME');
}
(Replace MYBUTTONNAME with the name you've given your button, and all the conditions you have added based on it will be interpreted correctly.)
Re: Dynamic action 'Confirm' problem [message #535298 is a reply to message #535293] Tue, 13 December 2011 06:59 Go to previous messageGo to next message
balckbandit5
Messages: 104
Registered: December 2011
Senior Member
Perfect!
Thanks a lot Smile
Re: Dynamic action 'Confirm' problem [message #535299 is a reply to message #535298] Tue, 13 December 2011 07:08 Go to previous messageGo to next message
c_stenersen
Messages: 255
Registered: August 2007
Senior Member
Just for future reference, it's also possible to do it with dynamic actions if you want to.

Then you add a dynamic action for the button, set as a condition type "javascript expression", the expression is this.browserEvent != 'load' && confirm('My question?') (if I didn't add the browser event condition I got the popup also when the page loaded strangely enough, even if the dynamic action wasn't set to fire on page load.)
The action is "submit page", and you add the button name in the "request/button name" field.
Re: Dynamic action 'Confirm' problem [message #535313 is a reply to message #535299] Tue, 13 December 2011 08:35 Go to previous messageGo to next message
balckbandit5
Messages: 104
Registered: December 2011
Senior Member
Ok thanks, I think the first way is easier though Razz Would there be an advantage to doing it one way or the other?
Re: Dynamic action 'Confirm' problem [message #535315 is a reply to message #535313] Tue, 13 December 2011 08:41 Go to previous messageGo to next message
c_stenersen
Messages: 255
Registered: August 2007
Senior Member
I guess the advantage would be that with a dynamic action it's easier for a person who might maintain this thing apart from you (or even for yourself in case you forget) to see that there's something being triggered on click other than just submitting the page. But apart from that the functionality is the same so it shouldn't matter.
Re: Dynamic action 'Confirm' problem [message #535316 is a reply to message #535315] Tue, 13 December 2011 08:48 Go to previous message
balckbandit5
Messages: 104
Registered: December 2011
Senior Member
Oh right ok
Well thanks for your help
Previous Topic: Taken to allocated page after Login
Next Topic: Web service implementaion help
Goto Forum:
  


Current Time: Tue Mar 19 03:04:32 CDT 2024