Is there a way to submit a form when a checkbox is checked in Spring MVC?
Basically I have a bunch of input box that belongs to a particular form and there is a submit button which generate run an sql and display on the same page the result. I have a checkbox to generate the result in a dowloadable excel file. When I submit the checkbox it should do a submission but a different url than the form above it?
Any help or hint will be greatly appreciated it or an url how this can be done!!
I google on the internet but couldn't find an answer to my question.
This is a use-case for the params attribute: define 2 methods in controller with different params. As a value of the params, use the name and the value of the checkbox input.
Documentation: https://docs.spring.io/spring/docs/4.3.x/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping-params-and-headers
Related
I have a list of objects on my page. I need to edit an object in a popup.
There are many objects, and generating many forms for each object is not correct.
What can I do, can an iframe do in a popup?
You don't need to use iframe.
Build your form in your controller and render it in the html. The fact that it's in popup doesn't change anything. It doesn't matter if it's in popup or not, the final result will be POST call to your action.
You should have an action that renders a form, callable from an ajax in the view where you have all those entities.
Just change the entity id that will be received in the action as argument by changing the ajax url using js depending on the clicked entity you want to edit.
Then return with the ajax the form already rendered so with only one form you can edit as many entities (of the same class) as you want, without even need to render one form before they click which one they want to edit.
We have required conditional file field that depends on another dropdown field. If dropdown field value YES then file field will show and added required option but if dropdown value NO then file field not show and remove the required option.
We have done the hide show logic in file field but not able to do required option on off. Can anyone please suggest how to do that?
Without the exact website link, it is difficult to explain perfectly. However, from what I understand what you need to do here is to implement a custom validation.
You can refer this link to understand how to implement custom validation.
Basic flow of code:
1. Give ID to the drop down so that you can bind an onchange event with it
2. Bind an onchange event that hide/show the file field
3. Create custom required validation which checks your drop down value and decides whether the other field is required or not
This should do your job... Feel free to ask other questions and post your website uRL and code to get a better answer.
I have a form in an asp.net mvc view.
The form contains a textbox which is used to edit the username property of my model.
I want to add the bootstraps typeahead to this textbox searching the users while typing.
As far as I know the typeahead should post a form, but I can not put a form inside a form (since I want to use the typeaheads search result in form postback).
How can I solve it? Can it be done without using Ajax?
EDIT:
It's important that the selected username influences the content of the form. So somehow I have to post the typeahead selection, which in the server modifies the model and the result is an updated form. After that the user fills the remained fields than posts the form.
Typeahead can work on any <input type="text">, you should inspect the element in the examples. When you do you will notice that the input has a data binding called data-source which is just an array of strings. It then filters those strings whenever you type.
You could certainly populate that array via ajax. You might want to find some way to disassociate that <input> from the form though. Although it's probably not a big deal breaker.
I am looking for the best/easiest way to open/start a new gravity form when the current form fails validation. Example: user enters a zip code that is not valid upon submission. When the form fails validation a second form opens which is used to gather user contact info so they can be notified when their zip code is available.
Does anyone have an answer already to this that I was unable to find in the search or have any ideas as to a solution?
Thanks in advance.
You would have to tap into the action "gform_after_submission" and do a redirect to another page with that form. http://www.gravityhelp.com/documentation/page/Gform_after_submission
Another option would be to provide a drop down list of all the available zip codes with an additional option, like "mine is not in list". Then have some other fields that have conditional logic to only show if the "mine is not in list" value is selected.
http://www.gravityhelp.com/documentation/page/Form_Settings ( look for the conditional logic section)
Hope that helps.
So, when i was dealing with forms before what i would do is find web element that is part of the form input, set value of that form input by element.setattribute("value", "infoi want to add")
then simply when i set value of form elements i click submit button of form.
Is this possible to do with web-form input type="file" and how can i do it?
Thanks
The simplest and the most straightforward way to do exactly what you've described is to get form's target address with QWebFrame::hitTestContent and then to post a file with QNetworkAccessManager::post. You also could inject some javascript code into a loaded page (see this for more details), but that would be an overkill for such a simple taks. And besides in the latter case all your injected javascript will be gone after submitting the form (i.e. after the page is reloaded).