0

I am not able to autofill autocomplete on load page.

Autocomplete work fine when call using direct action like

localhost:7070/StrutsDropDown/OtherBill.Action

But i want to call it on load page using ajax or using jquery.

Following things I have done.

My autocomplete is:

<s:label name="stateName" value="CustID:" /><s:autocompleter theme="simple" list="CustID" name="Cust_id"/>

My Action is:

private List CustID;
  public String execute(){
  CustID = new ArrayList();
  CustID.add("Alabama");
  CustID.add("Alaska");
  CustID.add("Arizona");
  CustID.add("Arkansas");
return SUCCESS;
}

So,How to fill autocomplete using ajax or jquery on

$(document).ready(function() {}

please somebody help me how to do it.

Alone
  • 313
  • 1
  • 8
  • 25

1 Answers1

1

You can use something called <s:url> tag through which u can trigger Action class....

In your Jsp page...

<s:url value="/OtherBill.Action" var="BillUrl" />
<s:a  href="%{BillUrl}">
  <button value="Check Bill Action" id="TriggerBillUrl"></button>
</s:a>

And your Jquery...

$( document ).ready(function() {
alert("Inside the document ready");
$('#TriggerBillUrl').trigger('click');
});

Hope yout got it..:) :)

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
goodyzain
  • 683
  • 2
  • 8
  • 21