Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By devoted.designer on
Hey guys,
How is it possible to create simple confirmation popup dialog boxes?! jQuery, javascript ... etc, anything!
I've searched a lot but found tons of non-working suggestions and code.
Please help!
Thanks for your time and help :)
Comments
Well, I don't know what have
Well, I don't know what have you tried and what do you need exactly... jQuery is a pretty reliable script, and has nice features - plugins but if you want to simply confirm form submission - for example - javascript is more than enough. A bit more info about what do you want to accomplish would help a little ;)
Here is a simple example of
Here is a simple example of javascript confirmation implementation for form API submit button:
this will submit the form only after user click OK on javascript confirmation dialog.
Hope it helps!
THANK YOU
THANK YOU MAN!!!!!!!!!!!!
YOUR A LIFE SAVER .... i don't believe how went off my mind ;)
Thanks again.
Using jQuery
The code you gave me worked like a charm, but i was wondering:
If i wish to use a jQuery plugin instead ... how is that possible?
I'm using a jQuery plugin called "Apprise", but don't seem to know how to get it to work!
I tried the following code in my form:
The apprise function is correctly implemented ... (I double checked).
Am I adding the jQuery plugin correctly?
Is this the right place to add the .js and .css?! (To insure that these js and css are only loaded once with the loading of the website)
How can i correctly implement the jQuery code in the attribute?
Sorry for asking too much, I'm a newbie :(
Thanks for your time and help
Ok, there is a few problems
Ok, there is a few problems with this code.
1st, the current Apprise module is not compatible with Drupal 7's jquery implementation because it uses $. so 1st of all what you need to do is download the non minimized version of the plugin and replace all the $ characters with "jQuery". Here is the modified version:
then here is an example for the proper implementation:
make sure to change jQuery("#b2test-form1").submit(); to your form's id (it's your form function name, just replave _ to -).
Another tip:
To see if you have included everything correctly, or basically for jQuery debug either use Chrome's built in debugging functionality, or Firefox with Firebug plugin ;)
Hope this helps.
I take my hat off to you!
I take my hat off to you!
Thank you so much for your time and invaluable help.
TOTAL RESPECT :)
I still have a tiny question:
You used the default form submit, what if I wanted to call a custom-named function?
That is, in case I have 2 submit buttons, each with it's own submit array!?
such as:
What should i replace jQuery("#myform").submit(); with?
Well, You can always define a
Well, You can always define a hidden element in your form, and set its value to something to verify which button was pressed, and do different action based on that value. for example: instead of
you add a hidden field:
then add a javascript code
or
and in yourform_submit(... function just do different things for $form['values']['myhiddenvaluefield']=='delete' ... you get the idea.
Hidden fields got no id!!!
Hidden fields got no id!!! (I checked that via firebug)
That's why i can't seem to be able to select that field to change it's value!
I replaced the hidden field with a text field, selected it using the jQuery function (you gave me) and changed its value perfectly.
But a textfield can't be used here! A hidden one must be used ....
I also tried to select it (hidden field) using jQuery selectors ... but no luck:
jQuery("input[name="myhiddenvaluefield"]").val("save");
Any Ideas ?
You can add an id like
You can add an id like this:
it will result:
I'm speechless :)
I don't know why such simple solutions didn't come to my mind?!
Honestly ... I don't know what to say :)
Thank you so much for your time and help ...
You are welcome!
You are welcome!
Thanks alot
Thanks :)
I've been looking for a solution to this for some time. I had the idea at some point, that I could maybe do this, but according to the FAPI '#attributes' is not supported for hidden fields: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.... . How can that be?
Thanks
Thanks, it works fine for me
How to use?
Hello,
i hope this code will work for me, But pls let me know the steps to use this code.
thanks
Node Save Confirmation?
How could I get this to work on a node Save button? And where does this code go?
Issue wen there i stwo submit button
Hi
I have used your suggestion it worked fine thank alot. But today got stuck in some awkward thing. as my senerio is I have two submit button. One Approves and other Not Approve. When I press the approve button it goes to the approve function and run it. and when i Not approve, it first confirms and when pressed OK it runs the not Approve function.
But the issue comes when I press the Not Approve button the confirmation appears I press cancel. Nothing happens. When I press the Approve Button it goes to the Not approve Submit Function. Not getting the idea why it is doing so. Please suggest any solution for it.
bboldi, thx a lot! Your
bboldi, thx a lot! Your solution is the easiest and it works!
It's important to remember that many things are form element's #attributes.
Thank you!
Thank you so much MEN.
Thank you so much MEN.
Your are a life saver
custom module creation
Hi,
I have followed the D7 custom module creation tutorial. But I need some more information with reference codes.
I need to build up a admin controlled custom module with some text boxes, checkboxes / radiobuttons, along with image upload feature. I need to add,edit, delete those values from admin & the added values will show in the front end. Can anyone please help me with some reference codes of any type of custom module for above mentioned type.
Help will be much appreciated.
Thanks in advance...
Thank you very much for this
Thank you very much for this code. I will try to use it for every node delete confirmation on Drupal 6 and I'll post here if it works.
EDIT //
I thought it would be easier but I guess was presomptuous :)
I tried to use apprise on this form but it doesn't work :
Do I also have to change the apprise code like you did for D7 ?
Thank you
I have not tried it, but I
I have not tried it, but I think that you don't need to change the jQuery module for Drupal 7.
Thanks a lot!!!
Thanks a lot!!!