I have a combobox element from jquery-easyui:
<form name="myform" method="post"><input id="city"
class="easyui-combobox"
data-option="valuefield:'id_city', Textfield:'name_city', Url:'getcity.php', method:'get'"/> </form>
When myform submits
I'm using $_Post['city'] to get a valuefield and it works.
But how to get a textfield using same method?
If you wish to retrieve the text from the combobox, set the 'valueField' and 'textField' with the same value. Or you can use the following method:
`$('#city').combobox('getText');`
Hope this may help you.
getText does not return the text in the input field if it is typed manually. It only works if the tree was used to select the text.
Related
At this point I'm just trying to getting the input from the form. When I hit submit it does nothing and show nothing in the terminal. I'm using Slim with Sinatra.
My two routes are
post '/user_search' do
puts params[:checkbox]
#slim :user_search_results
# commented because I just would like to see something in terminal.
end
get '/user_search_form' do
slim :user_search_form
end
I've tried creating a class for search as well as a helper method. None of those approaches have changed anything.
Finally here is the form. Granted I have some other forms that work find. Those use text fields, so maybe it is the checkboxes that are throwing things.
form method="POST" action="/user_search"
label for="mp3" mp3:
input type="checkbox" name="mp3" value="mp3"
label for="flac" flac:
input type="checkbox" name="flac" value="flac"
label for="ape" ape:
input type="checkbox" name="ape" value="ape"
label for="m4a" m4a:
input type="checkbox" name="m4a" value="m4a"
label for="jpg" jpg:
input type="checkbox" name="jpg" value="jpg"
label for="gif" gif:
input type="checkbox" name="gif" value="gif"
label for="png" png:
input type="checkbox" name="png" value="png"
input type="submit" value="Submit"
This is non database input. Just want to grab the params for a search method.
Wow, it all came down to indenting all the lines below action method. I also indented submit passed those above. Weird thing is other forms I have, have no indentation at all.
I've got a form where I want to edit some user data.
So the already stored data is put as th:value and after sending I validate with spring validation and want to give back the form on wrong input. I want the input field to have the value of the input by the user but it always gives me the stored input instead.
That's how an input field looks like
<input type="text" th:value="${product.name}" th:field="*{name}" th:errorclass="fieldError"/>
If the form is loaded the first time the input fields should have the value of the already stored data.
If it's loaded after submit and with an validation error, the input fields should have the value of the user's input.
Is there a way to to that?
Thanks!
Attribute th:field will replace attributes value, id and name in your input tag.
Instead, use plain th:id, th:value and th:name without using th:field. Then you will get what you wanted.
Then it will look like:
<input type="text" th:value="${product.name}" th:name="name" th:id="name" th:errorclass="fieldError"/>
Similar answer is here: How to set thymeleaf th:field value from other variable
Because Attribute th:field is Combination of both th:name and th:value
So, either use this:
<input type="text" th:value="${product.name}" th:name="name" th:errorclass="fieldError"/>
Or this:
<input type="text" th:field="*{name}" "th:errorclass="fieldError"/>
Using th:field or value, id and name is ok. if you user th:field, you can write this:
<input type="text" th:field="${product.name}" th:value="${product.name}" "th:errorclass="fieldError"/>
You have error in your controller (you set wrong value to *{name}), if the input value is wrong after validation error.
I am using Sitecore 7.1. I created one search page and created a textbox by using the Web Form For marketer in it. On button click I want catch the text box value in a new page name search-result. How can I catch the WFFFM text box value in New page? I Don't want use JavaScript click event and query string.
<form class="search-form" action="/searchresults" method='get' >
<label><input type="text" name="searchText" id="searchText" placeholder="#placeholderText"></label>
<input type="submit" name="submit" value="" class="#cssClass">
</form>
But i am getting below type of URL
http://www.xyz/searchresults?searchText=searchTextHere&submit=
Can you capture the "onsubmit" event and update the URL to whatever you need using Javascript? You only said not to use onclick event. I'm assuming that you may want to have /searchresults/ as a result. Of course, I assume that your routes are set for this and searchresults can process this correctly.
Hi I tried adding a range from 1-10 to a field in my model and it caused 2 mini arrows to appear to the right of my editor field that increment and decrement the value inside by 1. I would like to know how to remove these arrows. Any advice would be great. Thanks
Instead of using #Html.Editor html helper, use #Html.TextBox, this will solve your problem.
Because the property type is integer, if you'r using #Html.Editor, it will generate html like below:
<input type="number" id="Data" />
Notice the input element type is number, if your browser support HTML 5, it will show two arrows to the right. It's an html 5 feature.
But, if you're using #Html.TextBox, it will generate html like below:
<input type="text" id="Data" />
This time the type is text, it will not show the arrows.
I have <button onclick="doSomething();">Do something</button> inside form_for helper. Сlicking on it causes form submission. Instead I want only to do something client-side work for what it is intended.
How can I achieve it?
EDIT: I can use only <button> tag for my purposes and it'll be rather well if I could place it inside form.
It's pretty easy: just add water return false;. See example:
<button onclick="doSomething();return false;">Do something</button>
I need weekend rest and 5 minutes googling after :)
EDIT: Working method with <form>
Make sure your button is written like this:
<input type="button" onclick="doSomething()">
You can select the the form by it's index. So if this is the first <form> element on your web page, it's index would be 0. And so on. The index is the order of the elements. If you're having trouble with this, you can always name your form and select it by name. Here's how:
var form = document.forms[0]; //selecting by index
var namedForm = document.forms["someForm"]; //Selects <form name="someForm">
var name = form.elements["nameInput"].value; //Selects <input type="text" name="nameInput">
And so forth. Let me know if you run into any trouble with this.
<button onclick="doSomething();void(0)">Do something</button>
Although it's usually better practice to hook into the button's click event from JavaScript, separating concerns.