AutoSubmit using JQuery
<%@ include file="init.jsp"%>
<%@ taglib uri="http://java.sun.com/ portlet_2_0" prefix="portlet"%>
<jsp:useBean class="java.lang.String" id="addNameUrl" scope="request" />
<jsp:useBean class="java.lang.String" id="make" scope="request" />
<jsp:useBean class="java.lang.String" id="model" scope="request" />
<script type="text/javascript">
jQuery(document).ready( function(){
jQuery('#make').change( function(){
jQuery('#model').show();
var theValue = jQuery("#make").val();
jQuery("#make").val( theValue ).attr('selected',true);
jQuery('.addForm').submit();
});
});
jQuery(document).ready( function(){
jQuery('#model').change( function(){
var theValue = jQuery("#model").val();;
jQuery("#model").val( theValue ).attr('selected',true);
jQuery('.addForm').submit();
});
});
</script>
<portlet:defineObjects />
<%
List products = (List) CalculateLocalServiceUtil. getAllProducts();
Deductible product = null;
%>
<form id="<portlet:namespace />addForm" action="<%=addNameUrl%>"
method="post" class="addForm">
<%
System.out.println("In view.jsp");
System.out.println(products. size());
if (make != null && make != "") {
%> <select name="make" id="make" size=1 width=10 >
<%
for (int i = 0; i < products.size(); i++) {
product = (Deductible) products.get(i);
if (!product.getMake().equals( make)) {
%>
<Option><%=product.getMake()%> </option>
<%
} else {
%><Option selected><%=product.getMake()% ></option>
<%
}
}
%>
</select> <%
} else {
%> <select name="make" id="make" size=1 width=10>
<%
for (int i = 0; i < products.size(); i++) {
product = (Deductible) products.get(i);
%>
<Option><%=product.getMake()%> </option>
<%
}
%>
</select> <%
}
%>
<%
if (make != null && make != "") {
%> <select name="model" id="model" size=1 width=10>
<%
for (int i = 0; i < products.size(); i++) {
product = (Deductible) products.get(i);
if (product.getMake().equals( make)) {
if(product.getModel().equals( model)){
%>
<Option selected><%=product.getModel() %></option>
<%
}else {
%> <Option><%=product.getModel()% ></option>
<%
}
}
}%>
</select>
<%} if (make != null && make != "" && model!=null && model!=""){ %>
<%
for (int i = 0; i < products.size(); i++) {
product = (Deductible) products.get(i);
if (product.getModel().equals( model)&& product.getMake().equals(make) ){
%>
<label for="text1" id="label1"><%=product. getDeductible()%></label>
<%
make="";
model="";
}
}
}
%>
</form>
<%@ include file="init.jsp"%>
<%@ taglib uri="http://java.sun.com/
<jsp:useBean class="java.lang.String" id="addNameUrl" scope="request" />
<jsp:useBean class="java.lang.String" id="make" scope="request" />
<jsp:useBean class="java.lang.String" id="model" scope="request" />
<script type="text/javascript">
jQuery(document).ready(
jQuery('#make').change(
jQuery('#model').show();
var theValue = jQuery("#make").val();
jQuery("#make").val( theValue ).attr('selected',true);
jQuery('.addForm').submit();
});
});
jQuery(document).ready(
jQuery('#model').change(
var theValue = jQuery("#model").val();;
jQuery("#model").val( theValue ).attr('selected',true);
jQuery('.addForm').submit();
});
});
</script>
<portlet:defineObjects />
<%
List products = (List) CalculateLocalServiceUtil.
Deductible product = null;
%>
<form id="<portlet:namespace />addForm" action="<%=addNameUrl%>"
method="post" class="addForm">
<%
System.out.println("In view.jsp");
System.out.println(products.
if (make != null && make != "") {
%> <select name="make" id="make" size=1 width=10 >
<%
for (int i = 0; i < products.size(); i++) {
product = (Deductible) products.get(i);
if (!product.getMake().equals(
%>
<Option><%=product.getMake()%>
<%
} else {
%><Option selected><%=product.getMake()%
<%
}
}
%>
</select> <%
} else {
%> <select name="make" id="make" size=1 width=10>
<%
for (int i = 0; i < products.size(); i++) {
product = (Deductible) products.get(i);
%>
<Option><%=product.getMake()%>
<%
}
%>
</select> <%
}
%>
<%
if (make != null && make != "") {
%> <select name="model" id="model" size=1 width=10>
<%
for (int i = 0; i < products.size(); i++) {
product = (Deductible) products.get(i);
if (product.getMake().equals(
if(product.getModel().equals(
%>
<Option selected><%=product.getModel()
<%
}else {
%> <Option><%=product.getModel()%
<%
}
}
}%>
</select>
<%} if (make != null && make != "" && model!=null && model!=""){ %>
<%
for (int i = 0; i < products.size(); i++) {
product = (Deductible) products.get(i);
if (product.getModel().equals(
%>
<label for="text1" id="label1"><%=product.
<%
make="";
model="";
}
}
}
%>
</form>
No comments:
Post a Comment