I've searched around the net but I have not found a solution.
Is there something like numeric up down, for numeric selection in Grails?
How can I create it?
You can achieve your requirement via simple html as:
<input type="number" name="quantity">
you can set range also as:
<input type="number" name="quantity" min="1" max="5">
and If you want you can add value attribute to be shown as:
<input type="number" name="quantity" min="1" max="5" value="${domainInstace.attribute}">
and Enjoy.......
Within a gsp ?
<g:select id="orderby" name="orderby" from="${1..10}" noSelection="['':'-Define Display Order 1 top 10 bottom-']" required="" value="${youdomainClassInstance?.orderby}" class="many-to-one"/>
Related
I use thymeleaf 3
I try to use a condition with th:attr with some value
<input type="text" class="form-control" th:id="'genericForm'+${genericField.field}" th:attr="${genericField.mandatory} ? data-msg=#{mandatory.field}, name=${genericField.field} : name=${genericField.field}"/>
Actually, this input is not displayed
error is:
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as assignation sequence:
Any idea?
Like this is how I would do it:
<input type="text" class="form-control" th:id="'genericForm'+${genericField.field}" th:name="${genericField.field}" th:attr="${genericField.mandatory} ? data-msg=#{mandatory.field}"/>
You can move name out to th:name since it's in both.
I'm trying to design an input that is limited to 8 characters of any value 0 through 9. Seems simple enough, right?
So, I use this:
<input type="number" id="test4" min="0" max="99999999" pattern="\d*">
And things work perfectly - with a simple caveat. The max number is not being respected. So, I tried these:
<input type="number" id="test2" min="0" max="99999999" pattern="\d{0,8}">
<input type="number" id="test3" min="0" max="99999999" pattern="[0-9]{0,8}">
Both of these two revert the iOS keyboard back to the expanded entry and not just the 10 digits. What am I missing? How can I get this input to display the 10-digit iOS keyboard and also be restricted to 8 digits?
(I know that I could simply use JS to cap the entry, but I was trying to avoid that)
Thanks,
This seems to work:
<input type="text" maxlength="8" pattern="\d*">
I have a ViewBag like this
ViewBag.ApplyDiscount = false;
ViewBag.ExpressShip = true;
ViewBag.Supplier = null;
and some cshtml snippets like this
Discount:<input type="checkbox" checked="#ViewBag.ApplyDiscount"/>
Express:<input type="checkbox" checked="#ViewBag.ExpressShip"/>
Supplier:<input type="checkbox" checked="#ViewBag.Supplier"/>
after razor rendered the cshtml snippets,the real html will be
Discount:<input type="checkbox"/>
Express:<input type="checkbox" checked="checked"/>
Supplier:<input type="checkbox"/>
but if I add a space between the checked attribute and =like
Discount:<input type="checkbox" checked ="#ViewBag.ApplyDiscount"/>
Express:<input type="checkbox" checked ="#ViewBag.ExpressShip"/>
Supplier:<input type="checkbox" checked ="#ViewBag.Supplier"/>
razor will render the cshtml snippet in a wrong way. The html will be like this:
Discount:<input type="checkbox" checked ="False"/>
Express:<input type="checkbox" checked ="True"/>
Supplier:<input type="checkbox" checked =""/>
This will happen no matter MVC4(VS2012) or MVC5(VS2015).
So, can anyone tell me why a space will cause this thing to happen?
Because checked itself is a special stand-alone boolean attribute from legacy HTML and can be valid syntax without an attribute value.
It's presence alone indicates that the box is checked.
e.g.
<input type="checkbox" checked />
and
<input type="checkbox" checked="true" />
Perform the same way. It's why in jquery we always use the :checked selector. It obfuscates the need to check the variation.
I thought I had the whole numeric keypad down and tested on ios 7. But I can't get the dashes, decimals or astericks button to appear.
Here is the code I thought would work:
<input type="number" pattern=[0-9]* inputmode=numeric name="rx1" id="rx1" class="single fldrequired" value=""/>
However, it does not give the option to have dashes, decimals, astericks, etc. I expected it to be in the lower left corner of the keypad, but no such luck. I've tried different variations such as:
<input type="text" pattern=[0-9]* name="rx1" id="rx1" class="single fldrequired" value=""/>
<input type="number" pattern="\d*" name="rx1" id="rx1" class="single fldrequired" value=""/>
<input type="text" pattern="\d*" name="rx1" id="rx1" class="single fldrequired" value=""/>
None of them have produced the button for the extra characters. So for now, I'm just using:
<input type="number" name="rx1" id="rx1" class="single fldrequired" value=""/>
Is this an ios 7 thing or am I just doing something completely wrong. I tried "tel" as well, but that wasn't really what I was looking.
Thanks.
I have one checkbox use jQuery UI
<input type="checkbox" id="checkbox_1" name="checkbox_1" value="1" />
<label for="checkbox_1" class="checked">checkbox_1</label>
<script>
$(function){
$("input:checkbox").button();
};
</script>
And I query the data from database,the checkbox should be checked.
But it doesn't works when I added the attribute of "checked" in checkbox like normal usage.
How to achieve it?
add in html
<input type="checkbox"checked="checked"id="checkbox_1" name="checkbox_1" value="1" />