Reputation: 4353
I have a button and a text field adjacent to each other button has a dropdown ,when I select from the drop down value gets populated on button,I just need to send to both params i.e param of textfield and button to controller ,textfield param goes to controller when I submit form but not of button.
code:
<div class="controls">
<div class="input-append">
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown" id="protocol" name="abc">
protocol
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="javascript:void(0)" onclick="$('#protocol').html('http://');" >http://</a>
</li>
<li>
<a href="javascript:void(0)" onclick="$('#protocol').html('https://')" >https://</a>
</li>
<li>
<a href="javascript:void(0)" onclick="$('#protocol').html('ftp://')" >ftp://</a>
</li>
</ul>
</div>
<g:textField class="input-large" name="xyz" value=""/>
</div>
</div>
Is there any way to get the name of button and value on the button on controller side when I subimt the form.
e.g button has value 'http://' and textfield has value "stackoverflow.com" then on controller side i need like this "http://stackoverflow.com" when form is submitted.
Upvotes: 0
Views: 112
Reputation: 3704
Can't you create a hidden field an populate it with the selected value? It will definitely be sent with the request and available to you in the params.
<g:hiddenField name="selectedProtocol" />
<a href="javascript:void(0)" onclick="$('#protocol').html('https://'); $('#selectedProtocol').val('https://');" >https://</a>
Upvotes: 1