i need to set the radio button as checked based on the value present in the request. below is the code i used in my JSP
<input type="radio" name="status" id="status" value="Active" checked="<c:if test="${posting.postingStatus eq 'Active'}">checked</c:if>">
Active
<input type="radio" name="status" id="status" value="Closed" checked="<c:if test="${posting.postingStatus eq 'Closed'}">checked</c:if>">
Closed
I am getting the radiobutton along with the text 'checked/>Active' and another radio button with text 'checked/>Closed'
i tried using another set of code
<c:choose>
<c:when test="${posting.postingStatus eq 'Active'}">
<input type="radio" name="status" id="status" value="Active" checked="checked"/>
Active
<input type="radio" name="status" id="status" value="Closed"/>
Closed
</c:when>
<c:otherwise>
<input type="radio" name="status" id="status" value="Active" />
Active
<input type="radio" name="status" id="status" value="Closed" checked="checked"/>
Closed
</c:otherwise>
i am getting double times with improper result.
can anyone help me with this?
Try this way:
<input type="radio" name="status" id="status"
value="Active" ${posting.postingStatus=='Active'?'checked':''}>
Related
I have two input value like this
<input type="text" th:field="*{itemID}"placeholder="Bidding id" class="form-
control" required />
------------
<input type="hidden" th:field="*{item.id}" />
okay so how can i put the value of item.id field into itemID ?. I tried like below but it didn't work
<input type="hidden" th:field="*{itemID}" th:value="*{item.id}"
placeholder="Bidding id" class="form-control" required />
update
i tried to make it like this, but it still not work
<input type="hidden" th:name="*{itemID}" th:value="1"
placeholder="Bidding id" class="form-control" required />
Try this :
<input type="hidden" th:field="*{itemID}" th:value="${item.id}" placeholder="Bidding id" class="form-control" required />
replace the * by $ in th:value attribute
How do I disable a submit button in JSTL if the text field is blank or empty?
<input id="name" name="name" type="text" autocomplete="off" />
<input id="namebutton" type="submit" />
I'm looking to have two radio groups within a single form. When you select a radio button (product type) form the first group, I'd like to update the second group (quantity) and adjust the price using Ajax. Does Grails offer an Ajax radio solution?
<form>
<div>
Product Type
<input type="radio" name="q1" value="1"/>
<input type="radio" name="q1" value="2"/>
<input type="radio" name="q1" value="3"/>
</div>
<div>
Quantity
<input type="radio" name="q2" value="1"/> ${price}
<input type="radio" name="q2" value="2"/> ${price}
<input type="radio" name="q2" value="3"/> ${price}
<input type="radio" name="q2" value="4"/> ${price}
<input type="radio" name="q2" value="5"/> ${price}
</div>
<input type="submit" name="submit" id="submit" />
</form>
Take a look at the g:formRemote tag:
http://grails.github.io/grails-doc/2.1.0/ref/Tags/formRemote.html
My Magento contact form has the field names prefilled, not labelled.
<input name="name" id="name" value="Name" class="required-entry input-text" type="text" />
Since the field is prefilled, the validation "required-entry" fails.
Is there a not-so-dirty way to get the validation working with prefilled values?
just try to use. Placeholder to make prefilled text
<form action="demo_form.asp">
<input type="text" name="fname" placeholder="First name"><br>
<input type="text" name="lname" placeholder="Last name"><br>
<input type="submit" value="Submit">
</form>
that would sure help you.
Say I have a simple cfform that looks like this:
<cfform id="fruitForm" method="post" action="">
<cfinput type="radio" name="fruit" id="fruit_apple" value="Apple" /><label for="fruit_apple">Apple</label><br />
<cfinput type="radio" name="fruit" id="fruit_orange" value="Orange" /><label for="fruit_orange">Orange</label><br />
<cfinput type="radio" name="fruit" id="fruit_pear" value="Pear" /><label for="fruit_pear">Pear</label><br />
<cfinput type="submit" name="submitFruit" id="submitFruit" value="Submit" />
</cfform>
How can I use the built-in cfform validation to ensure that at least one radio button in this group is selected? I've tried adding a validate="required" to each of the radio buttons but it doesn't work. Is there any simple way to "require" one of the buttons to be selected using cfform validation?
Do yourself a favor and don't use cfform for validation. Write your own server and client side validation, but according to the cfinput documentation if you add a required="true" attribute to each radio button ColdFusion will do the client side validation for you.
Note: The user can bypass this validation and still submit a form without checking a radio button. You need to have server side validation as well.
<cfform id="fruitForm" method="post" action="">
<cfinput type="radio" name="fruit" id="fruit_apple" value="Apple" required="true" /><label for="fruit_apple">Apple</label><br />
<cfinput type="radio" name="fruit" id="fruit_orange" value="Orange" required="true" /><label for="fruit_orange">Orange</label><br />
<cfinput type="radio" name="fruit" id="fruit_pear" value="Pear" required="true" /><label for="fruit_pear">Pear</label><br />
<cfinput type="submit" name="submitFruit" id="submitFruit" value="Submit" />
</cfform>
This works for me:
<cfform action="abc.cfm" method="post">
<cfinput type="radio" required="yes" message="pick something" name="x" value="1">radio 1
<cfinput type="radio" required="yes" message="pick something" name="x" value="">radio 2
<input type="submit" />
</cfform>
In fact, you don't even need the message attribute. It will still validate.