Hi I have a basic form in one of my Ruby On Rails views, it has an input tag and a placeholder. When I submit the form and then try to add another entry the values are kept from previously, what is the simplest way to clear the form fields after submitting. I guess I need to call some javascript onsubmit action when the form is submitted?
If someone could show me a simple example it would be great
Related
I want to reload part of my page upon form submit.
To do this i´d like to extract the selected fields from a Django multiselectfield.
Now I´m kinda stuck because Django renders the form like this:
Instead of select-Tags.
How can i extract which choices have been selected?
Or is there any way to return new information when the form has been selected without leaving the page?
You get the value in exactly the same way as for any other form field: via form.cleaned_data. In this case, form.cleaned_data['Messwerte'].
So, I'm having a little issue here with angular and forms
I'm creating a dynamic form, and it works correctly, but I needed to add some validations.
So I started to follow this guide and I set it up correctly, but when I set the form tags to surround my form controls, I'm getting a blank form
But, if I comment the form tags, I get my form perfectly
Any idea of why this is happening???
I have a couple of validation to show fields based on values, like
custConfig is part of the scope, could the name of the form be interfering with the retrieval of the custConfig variable? and if its such, how can I fix this?
Thanks
Your using a repeater
ng-repeat="deliver in shipmentDetails"
Do you have anything in your object shipmentDetails array? if not then the form will not show anything
I have a form with many different input fields (some of them are not really input but behave as inputs).
When submitting the from from the regular button click each field is validated through angular validation and html - such as required, ng-maxlength, minlength, etc..
Now we want to add a shortcut to submit the form on keyboard click. That code is running from the controller behind the html. How can I check the validity of the form from there? I know I can get the form by document.forms["myForm"] but can I use that somehow to check the validity same way as .$valid is working in the html? Could I somehow show the error messages on the html as well?
I tried to add jQuery validation plugin for that but seems like it is too much work to change the entire validation mechanism
Don't get the form withdocument.forms["myForm"]".
It's bad practice to use DOM manipulation inside a controller.
You can access the form with $scope.myForm. But beware of the fact that it will be initialised asynchronously.
But that shouldn't be a problem when you want to access the form after a keyboard click.
When you access the form with $scope.myForm you can iterate throw the $$controls. In this object are all form fields.
For example you can do it like this:
angular.forEach($scope.myForm.$$controls, function(value, key) {
value.$setDirty();
value.$setTouched();
});
And one more reminder when you use angular don't try do use JQuery for everything. If you want to use plugins search for angular plugins
I currently have two forms doing two separate actions.
One form subscribes a user to a mailchimp list. The other allows a user to submit their cv.
However I have two submit buttons, one for each action. I want to condense this down to just one submit.
Here is my jsfiddle: http://jsfiddle.net/GSVY8/
.
The end result should be that on submission the CV should be sent to me, and then the form for mailchimp should be submitted.
Any ideas would be much appreciated.
Cheers, Matt
You are using two different actions, so you need to different forms! Without the tag, the input button is useless anyway!
Validate the form in both client-side and server-side
So just wrap each submit button in a different form with a different action/validation and you're done!
I wonder if anyone can advise? I have a JSP which contains two forms, both of which are mapped to the same servlet on the server.
Everything seems fine although when I submit one form, a necessary piece of data entered on the other form is not being submitted at the same time.
The first form is used to add or delete the address of an RSS feed. As there may be several addresses on the page, a table is used to store them. Each cell of the table contains a form like this for deletion:
<form action = "<c:url value = '/deleteRSSFeed?rssFeedURL=${rssFeedURL}' />" method = "post">
<input type = "image" src = "${imageFileURL}myApp_rightArrow.png" />
<input name = "writeWordcloud" type = "hidden" value = "true" />
</form>
And there is another form for adding a feed.
The situation is that upon submission of either of these forms, a wordcloud must be redrawn on the page. But the wordcloud's settings are contained in the other form.
As it not possible for me to merge the forms, can anyone tell me if I can share data betwen forms in HTML? Or better yet, is it possible to submit one form, and have this action submit the second form?
At this point, it is not practical for me to have the forms served by different servlets.
Thanks
Mr Morgan
By using Javascript (or better, jQuery), you can have hidden fields in one form get the other form's fields values before submitting.
Update
This fiddle shows the code you need: http://jsfiddle.net/MqsK8/1/
You should probably use a single form, and have the server-side script perform both actions.
Depending on your scenario, you may want to have two submit buttons for different tasks; the server can check which button was clicked.
It would if you can provide detail of what you are trying to do. You can use Javascript to add elements to DOM but again all of this will depend on your use-case.