Archive for November, 2008
Checkbox selection logic
This js restricts the selection from a group of checkboxes to four. If a fifth one is selected , then the first one whichever was selected will be unchecked.
A combination of js and jQuery.
// Restricting the vehicle selection to FOUR – Start
var vehList=new Array();
vehList[0]=””;
vehList[1]=””;
vehList[2]=””;
vehList[3]=””;
var vehObjList = new Array();
vehObjList[0]=””;
vehObjList[1]=””;
vehObjList[2]=””;
vehObjList[3]=””;
function restrictVeh(obj,name){
var selVin = name;
var remVeh = “”;
var remObj;
if($(obj).attr(’checked’)){
for(var incr=0;incr <= 3 ; incr++){
if(vehList[incr]==””){
vehList[incr]=selVin;
vehObjList[incr]=obj;
break;
}
if(incr==3){
remVeh = vehList[0];
remObj = vehObjList[0];
$(remObj).attr(’checked’,false);
for(var cnt=0;cnt<3;cnt++){
vehList[cnt]=vehList[cnt+1];
vehObjList[cnt]= vehObjList[cnt+1];
}
vehList[3]=selVin;
vehObjList[3]=obj;
}
}
}else{
for(var incr=0;incr <= 3 ; incr++){
if(vehList[incr]==selVin){
vehList[incr]=””;
vehObjList[incr]=””;
for(var cnt=incr;cnt<3;cnt++){
vehList[cnt]=vehList[cnt+1];
vehObjList[cnt]=vehObjList[cnt+1]
}
vehList[3]=””;
vehObjList[3]=””;
}
}
}
/* for(var incr=0;incr <= 3 ; incr++){
alert(vehList[incr]);
} */
}
// Restricting the vehicle selection to FOUR – End
Add comment November 30, 2008
Pagination
<!– Pagination code starts here –>
<%
String numResults = (String)request.getAttribute(“usedVehicleCount”);
String index = request.getParameter(“startIndex”);
int pages = 1 ;
int numResultsPerPage = 12;
int remain = 0;
int total = 0;
int resultIndex = 0;
String showStart = “”;
String showEnd = “”;
String offsetVal = “”;
if(numResults!=null){
pages = Integer.parseInt(numResults)/numResultsPerPage;
remain = Integer.parseInt(numResults)%numResultsPerPage;
total = Integer.parseInt(numResults);
}
if(index==null){
resultIndex = 0 ;
}else{
resultIndex = Integer.parseInt(index);
}
if(remain!=0&&(total>numResultsPerPage)){
pages = pages + 1;
}
// Start value to display
if(index == null){
showStart = “1″;
}else{
showStart = String.valueOf(Integer.parseInt(index)+1);
}
// End value to display
if(total<=numResultsPerPage||((resultIndex+numResultsPerPage)>total)){
showEnd = numResults;
}else {
showEnd = String.valueOf(resultIndex+numResultsPerPage);
}
//Offset value
offsetVal = String.valueOf(resultIndex);
%>
<!– Pagination code ends here –>
——————————————————————
<%if(resultIndex != 0) {%>
<a href=”javascript:frameURL(<%=resultIndex-numResultsPerPage%>)” title=”Previous”>Previous</a>
<%}%>
<a href=”#” ><% out.println(“Showing “+ showStart + ” – ” + showEnd +” of ” + numResults); %></a>
<%if(Integer.parseInt(showEnd)<total){%>
<a href=”javascript:frameURL(<%=resultIndex+numResultsPerPage%>)” title=”Next”>Next</a>
<%}%>
—————————————-
<logic:iterate id=”usedVehicle” name=”usedVehicleList” type=”java.util.Properties” offset=”<%=offsetVal %>” length=”12″>
Add comment November 21, 2008
Pagination
<!– Pagination code starts here –>
<%
String numResults = (String)request.getAttribute(“usedVehicleCount”);
String index = request.getParameter(“startIndex”);
int pages = 1 ;
int numResultsPerPage = 12;
int remain = 0;
int total = 0;
int resultIndex = 0;
String showStart = “”;
String showEnd = “”;
String offsetVal = “”;
if(numResults!=null){
pages = Integer.parseInt(numResults)/numResultsPerPage;
remain = Integer.parseInt(numResults)%numResultsPerPage;
total = Integer.parseInt(numResults);
}
if(index==null){
resultIndex = 0 ;
}else{
resultIndex = Integer.parseInt(index);
}
if(remain!=0&&(total>numResultsPerPage)){
pages = pages + 1;
}
// Start value to display
if(index == null){
showStart = “1″;
}else{
showStart = String.valueOf(Integer.parseInt(index)+1);
}
// End value to display
if(total<=numResultsPerPage||((resultIndex+numResultsPerPage)>total)){
showEnd = numResults;
}else {
showEnd = String.valueOf(resultIndex+numResultsPerPage);
}
//Offset value
offsetVal = String.valueOf(resultIndex);
%>
<!– Pagination code ends here –>
———————————————————————-
<%if(resultIndex != 0) {%>
<a href=”javascript:frameURL(<%=resultIndex-numResultsPerPage%>)” title=”Previous”>Previous</a>
<%}%>
<a href=”#” ><% out.println(“Showing “+ showStart + ” – ” + showEnd +” of ” + numResults); %></a>
<%if(Integer.parseInt(showEnd)<total){%>
<a href=”javascript:frameURL(<%=resultIndex+numResultsPerPage%>)” title=”Next”>Next</a>
<%}%>
—————————————————————————
<logic:iterate id=”usedVehicle” name=”usedVehicleList” type=”java.util.Properties” offset=”<%=offsetVal %>” length=”12″>
Add comment November 21, 2008