How to use submit button in grails with if-else statement? - grails

I am now currently working on a grails project. I have a problem with my <g:submitButton> tag, and I am using a web flow. What I wanted to do is to proceed on the next page using <g:submitButton> if the input from the user is 1, while display a pop up window with options OK and Cancel buttons if the input is 0. If Ok button is clicked, the user will be redirected into a certain page, same through if the Cancel button is clicked.
Have anyone tried this?
Please help!

I guess you need some javascript in your form tag for this functionality. Search for “html form onsubmit“ and you'll find some good resources.

Related

how to hold the state of the checkbox while doing pagination in struts2

I am using struts2 to develop an application in that I have done pagination using Display tag
In pagination I have generated one check box per a row(some of them are checked) When user checks them and paginate to second page and when he come back to first page all are unchecked
If you need any code I will provide you
PLease tell me the way that can solve my issue.
Thanks IN Advance

Rails, Logout on Back Button in Browser

Quick question here.
I'm creating a 3-step form for a user - all AJAX (and using Devise). The user is created on the first step, and updated on the second two steps.
Now, the issue is that if a user hits the back button in their browser to go back to the first step, the Devise automatically changes the form action to update. But, the my update action renders partials that should only be rendered in steps 2 and 3 via Ajax.
How can I make it so that the user is logged out when hitting the back button so that the first form is always a new_user form?
One solution is to disable back button in browser at all.
You can use a modal to implement the three steps. If you are using Ajax, use it at full.
By this, there is no "back" button on the browser. But you can still have "back" button on your modal window, in this case the back option is totally in your control.
Add
For usability you should allow users to update their info at any time, instead of forcing them to complete all right after signed up.
I don't know what your next two steps are. But you can
Setup the update method to render the next two steps if an user has not finished them, or render other info if finished.
Show a notice if an user is signed in but has not finished the two steps.
By these you should be able to ensure whatever the user do on their browser, he can see what he need to do next. These should be applicable to either Ajax or no Ajax.

jquery mobile - MVC: How to save input from popup dialogs

Newbie here, scratching my head on this one.
How do you normally save information specified in a popup dialog for use by other forms on your page?
Scenaro:
Click an options button, which pops up a dialog.
Set some checkboxes, radio buttons, etc...
Submit form (dialog seems to need it's own form)
Do you usually just save the inputs in a session, cookie, or do you have another way access your dialog controls from the main form?
Seems like I'm missing something basic, as it should be easy to set some options and use them on the rest of the page.
All advice appreciated!
If you are trying to pass data from one page/dialog to another see Passing parameters between pages

passing variable to jQuery from same Class

I have googled for 2days so far :) Not finding the right answer yet. So expert help is needed.
I am writing the webpage, where I use php and mysql. On the webpage, it display list of products. Next to each product there is a button called "Compare". When user press the button, it should pop up the dialog box and ask user to enter some info then user click submit or cancel in the dialog box. When user click submit in the dialog box, it should take user to another page, where he will be displayed with information he is looking for (hopefully)....
For dialog box I am using jQuery-ui dialog box. The challenge I am facing is when user click on "Compare" button, I need to pass the product information to dialog box. Because all the product info are extracted from mysql and loop with php to display, they all have same class. eg
product 1Compare
product 2Compare
So how do i know which product_info i need to pass? I thought of adding attribute to button and product info with number to distinguish which one is selected, then i need to have multiple multiple dialog function attached to each button.
Any thought will be much appriciated.
Thanks
Create a global variable to store the index.
When we click on any button, we will check it's index and store in it.
After opening the popup or just before showing the popup, access this index. Using this index, access the division in which the product contains. Get required details from there. Update data in dialog box. Show dialog box.
Also clear global variable when you close the dialog box.
You can get more information about index here : http://api.jquery.com/index/
Friends, please suggest better solutions if any.
Thanks.

Submit a form in a jQuery Dialog box and close upon successful POST to MVC Action

I am using the method from this question to create a pop-up to show a form where the user must "sign" it and then click submit. I have the pop-up working and displaying data. Now I want to submit the form to a POST action and close the pop-up if the POST was successful.
I have been scouring the internet looking for something close to what I think I am looking for, but seeing anything. Can someone offer me some direction?
You can either do it manually via http://api.jquery.com/jQuery.post/ (it has on success callback) or use jQuery ajax form plugin http://jquery.malsup.com/form

Resources