Fórum
How to get value from aui:autocomplete search textbox.
Piyush Ranjan, modificado 12 Anos atrás.
How to get value from aui:autocomplete search textbox.
New Member Postagens: 4 Data de Entrada: 02/01/12 Postagens Recentes
Hi,
I have created one form which contains one textbox which I created using aui:autocomplete .js (autocomplete is working here)and one search button.
when I click on search button,it will call some method().
How can I get the textbox value in that method.
eg:
Inside jsp
--------------------
<aui:script use="aui-autocomplete">
var ipaddr = [
['10.111.11.11' ],
[ '10.111.11.12' ],
[ '10.111.11.13' ],
];
new A.AutoComplete(
{
dataSource: ipaddr,
schema: {
resultFields: ['name']
},
matchKey: 'name',
typeAhead: true,
contentBox: '#IpAddress'
}
).render();
</aui:script>
<portlet:actionURL name="searchByIp" var="searchByIpURL" windowState="normal" />
<aui:form action="<%=searchByIpURL %>" method="POST" name="fm">
<table>
<tr><td><div id="IpAddress" ></div></td>
<td>
<aui:button-row>
<aui:button type="submit" name="display" value="Search by IpAddress" />
</aui:button-row>
</td>
</tr>
</table>
</aui:form>
Now, how can I get this Ip address textbox value in searchByIp() method.
I tried to get the value as below,but it is giving null value.
inside SearchPortlet Class file.
-----------------------------------------------
public void searchByIp(ActionRequest request, ActionResponse response)
throws Exception {
String Ip = ParamUtil.getString(request,"ipAddr");
response.setRenderParameter("searchvalue", Ip);
sendRedirect(request, response);
}
I have created one form which contains one textbox which I created using aui:autocomplete .js (autocomplete is working here)and one search button.
when I click on search button,it will call some method().
How can I get the textbox value in that method.
eg:
Inside jsp
--------------------
<aui:script use="aui-autocomplete">
var ipaddr = [
['10.111.11.11' ],
[ '10.111.11.12' ],
[ '10.111.11.13' ],
];
new A.AutoComplete(
{
dataSource: ipaddr,
schema: {
resultFields: ['name']
},
matchKey: 'name',
typeAhead: true,
contentBox: '#IpAddress'
}
).render();
</aui:script>
<portlet:actionURL name="searchByIp" var="searchByIpURL" windowState="normal" />
<aui:form action="<%=searchByIpURL %>" method="POST" name="fm">
<table>
<tr><td><div id="IpAddress" ></div></td>
<td>
<aui:button-row>
<aui:button type="submit" name="display" value="Search by IpAddress" />
</aui:button-row>
</td>
</tr>
</table>
</aui:form>
Now, how can I get this Ip address textbox value in searchByIp() method.
I tried to get the value as below,but it is giving null value.
inside SearchPortlet Class file.
-----------------------------------------------
public void searchByIp(ActionRequest request, ActionResponse response)
throws Exception {
String Ip = ParamUtil.getString(request,"ipAddr");
response.setRenderParameter("searchvalue", Ip);
sendRedirect(request, response);
}
Thomas Berg, modificado 12 Anos atrás.
RE: How to get value from aui:autocomplete search textbox.
Regular Member Postagens: 131 Data de Entrada: 07/09/09 Postagens Recentes
Looking at your code, there's no <input> or <text> element within your form. Is the input element created by applying A.Autocomplete to #ipAddress?
Try changing
so that "ipAddress" is an input element, e.g.,
If that does not solve your problem, use Firebug or similar to see which parameters are sent to your controller when pressing "Search by ipAddress".
Try changing
<tr><td><div id="IpAddress" ></div></td>
so that "ipAddress" is an input element, e.g.,
<input id="ipAddress" name="ipAddress" type="text">
If that does not solve your problem, use Firebug or similar to see which parameters are sent to your controller when pressing "Search by ipAddress".