Sometimes we will get a requirement that we need to hit the "Action URL" using java script function.
May be my blog will be help you fot that requirement.
<%
PortletURL actionURL = renderResponse.createActionURL();
actionURL.setParameter(ActionRequest.ACTION_NAME, "getPrice");
%>
// creating action URL which will hit the Action method called "getPrice".
<aui:form name="fm" method="POST" >
<aui:input type="text" name="price" label="" required="true" onclick="getPrice()" inlineLabel="true">
<aui:validator name="number"></aui:validator>
</aui:input>
<aui:button-row>
<aui:button type="submit" for="Submit" key="submit" value="Submit"/> </aui:button-row>
</aui:form>
// I have created one form with one text field when i click that field i need to call getPrice action URL
<script>
function getPrice() {
document.<portlet:namespace/>fm.action = '<%=actionURL.toString()%>';
document.<portlet:namespace/>fm.submit();
}
</script>
// The above javascript code is usefull to hit the aciton URL with javascript function without clicking the submit button through javascript we are clicking the submit button.
Hope this is helpfull for you
May be my blog will be help you fot that requirement.
<%
PortletURL actionURL = renderResponse.createActionURL();
actionURL.setParameter(ActionRequest.ACTION_NAME, "getPrice");
%>
// creating action URL which will hit the Action method called "getPrice".
<aui:form name="fm" method="POST" >
<aui:input type="text" name="price" label="" required="true" onclick="getPrice()" inlineLabel="true">
<aui:validator name="number"></aui:validator>
</aui:input>
<aui:button-row>
<aui:button type="submit" for="Submit" key="submit" value="Submit"/> </aui:button-row>
</aui:form>
// I have created one form with one text field when i click that field i need to call getPrice action URL
<script>
function getPrice() {
document.<portlet:namespace/>fm.action = '<%=actionURL.toString()%>';
document.<portlet:namespace/>fm.submit();
}
</script>
// The above javascript code is usefull to hit the aciton URL with javascript function without clicking the submit button through javascript we are clicking the submit button.
Hope this is helpfull for you
No comments:
Post a Comment