Grails ajax radio buttons - ajax

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

Related

bind radiobutton in mvc

Radio Button checked item should be true based on entry.isalbum value. Below is my View code..
#foreach(abc.Models.ddt entry in entrydetails)
{
#if(entry.isAlbum=="Album")
{
<input type="radio" id="c" name="isAlbum" checked="checked" value="Album" />
<label style="margin-right:10px" for="c"><span></span>Album</label>
}
<input type="radio" id="c1" name="isAlbum" value="Movies" />
<label style="margin-right:10px" for="c1"><span></span>Movies</label>
<input type="radio" id="c2" name="isAlbum" value="Single" />
<label style="margin-right:10px" for="c2"><span></span>Single</label>
</div>
}
}
foreach loop contain value stroed in database corresponding to Album, Movies or Single.
radio button checked should be true based on entry.isAlbum vale. How can we do this, please help to us? I have three radiobutton mention in above code. Radio Button checked will be true based on entry.Isalbum vale. Please help me
Try this:
<input type="radio" id="c" name="isAlbum" #if(entry.isAlbum=="Album"){<text>checked="checked"</text>} value="Album" />
<input type="radio" id="c1" name="isAlbum" #if(entry.isAlbum=="Movies"){<text>checked="checked"</text>} value="Movies" />
<input type="radio" id="c2" name="isAlbum" #if(entry.isAlbum=="Single"){<text>checked="checked"</text>} value="Single" />

How can I validate that a radio button was selected using cfform built-in validation?

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.

radio button auto check based on condition using jstl

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':''}>

use the hidden form value in virtuemart joomla

i want to use the hidden form value "virtuemart_product_price" a administrator\components\com_virtuemart\helpers\calculationh.php
this form is added in components\com_virtuemart\views\cart\tmpl\default.php ..
<form method="post" class="product js-recalculate" action="/ecomm/index.php/component/virtuemart/">
<div class="addtocart-bar">
<!-- <label for="quantity229" class="quantity_box">Quantity: </label> -->
<span class="quantity-box">
<input type="hidden" class="quantity-input js-recalculate" name="quantity[]" value="1"/>
</span>
<span class="addtocart-button">
<input type="submit" name="addtocart" class="addtocart-button" value="Pick free" title="Pick free" /> </span>
<div class="clear"></div>
</div>
<input type="hidden" name="virtuemart_product_price" value="5" />
<input type="hidden" class="pname" value="Custom Item"/>
<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="view" value="cart"/>
<noscript><input type="hidden" name="task" value="add"/></noscript>
<input type="hidden" name="virtuemart_product_id[]" value="<?php echo virtuemart_product_id;?>"/>
</form>
i tried to get but i can't find a solution.

Programmatically pass a url to an anonymous proxy like http://www.trycatchme.com

I'm using .net httpwebrequest &/or webclient class
How can i Progamatically pass a url to an anonymous proxy like http://www.trycatchme.com and get back a result
<form method="post" action="/index.php">
<input id="address_bar" type="text" name="q" value="http://www." onfocus="this.select()" />
<input id="surf_button" type="image" value="Surf Now" src="images/surfnowbtn.gif" />
<input type="hidden" name="hl[include_form]" value="1" />
<input type="hidden" name="hl[remove_scripts]" value="1" />
<input type="hidden" name="hl[accept_cookies]" value="1" />
<input type="hidden" name="hl[show_images]" value="1" />
<input type="hidden" name="hl[show_referer]" value="1" />
<input type="hidden" name="hl[base64_encode]" value="1" />
<input type="hidden" name="hl[strip_meta]" value="1" />
<input type="hidden" name="hl[session_cookies]" value="1" />
</form>
The HttpWebRequest.Proxy Property might be what you want.

Resources