GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  Programming  >  JSP
Go To First  |  Previous Question  |  Next Question 
 JSP  |  Question 127 of 184    Print  
I have a cancel_complaints page in ASP in which list of complaints r coming (2 records come at a time means page navigation).In that page some information is coming in table and i have given a checkbox in one Table column according to records in database table rows are generated.

That is multiple checkbox are generated with same name.I have put a validation that if user has selecetd none of checkbox alert message comes.
Problem is that when there are more than one row validation is going fine but when only one row remains validation does not goes fine.Below i am giving javascript function that i have used for validation.

----------function------------
function validatefield()
{
var j=0;
var lenvar=document.cancel_complaints.chksel.length;
//alert(eval(lenvar));
for (i = 0; i < lenvar; i++)
{if(document.cancel_complaints.chksel[i].checked)
{
j=j+1;
}
}

if(j==0)
{
alert("Please select atleast one checkbox");
return false;
}

else
{
return true;
document.cancel_complaints.submit();
}
}
----------
in case of one row(i.e only one record i.e only one checkbox) the value of lenvar is undefined and if there are more than one row the value of lenvar comes= (no of checkboxes)

i am unable to understand why there is problwm in counting in total no of checkboxes.

if somebody has solution then plz tell me.
thanks in advance

  
Total Answers and Comments: 1 Last Update: July 26, 2006     Asked by: kshivani 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 26, 2006 09:05:10   #1  
rajamuna Member Since: March 2006   Contribution: 9    

RE: I have a cancel_complaints page in ASP in which li...

Try the folowing Javascript Function :

---------------------

function validatefield()
{
var j 0;
var lenvar 0;
var lenEle document.cancel_complaints.elements.length;
for (i 0; i < lenEle; i++)
{
if((document.cancel_complaints.elements[i].type) checkbox )
{
lenvar lenvar + 1;
}
}


for (i 0; i < lenvar; i++)
{
if(lenvar 1)
{
if(document.cancel_complaints.chksel.checked)
{
j j+1;
}
}
else if(document.cancel_complaints.chksel[i].checked)
{
j j+1;
}
}

if(j 0)
{
alert( Please select atleast one checkbox );
return false;
}

else
{
return true;
document.cancel_complaints.submit();
}
}

------------------------


 
Is this answer useful? Yes | No

 Related Questions

Skill/Topic: Programming ConstructsA) None of the above B)  C)    
Latest Answer : isErrorpage attribute ...

Skill/Topic: Programming ConstructsA) Script language declarations, scriplets and expressions. B) JSP standard actions. C) JSP standard directivesD) A portable tag extension mechanism.  
Latest Answer : Script language declarations, scriplets and expressions. ...

Skill/Topic: Programming ConstructsA) B) C) D)  
Latest Answer : 1  2  ...

Skill/Topic: Programming ConstructsA) B) C) D)  
Latest Answer : code fragment valid tags is  scriptlet tag that is because code is directley placed  in the _ jsp service()  ...

Skill/Topic: Programming ConstructsA) None of the above B) content safeC) synchornisedD) thread safe  
Latest Answer : Thread Safe,so that no other request can interrupt. ...

The ________________________ when added to the user session tells us that the session timed out. 
Skill/Topic: Programming ConstructsA) SessionTotalTimeOutIndicator B) SessionTotalTimedoutIndicator C) SessionTimeoutIndicator D) SessionTimedoutIndicator  

Skill/Topic: Programming ConstructsA) jspDestroy()B) jspInit()C) _jspService()D) getParameter() 
Latest Answer : _jspService() ...

Skill/Topic: Programming ConstructsA) jspDestroy()B) jspInit()C) _jspService()D) getParameter() 
Latest Answer : jspDestroy() and jspInit() methods are overridden. ...

The tag %@include file=”.........” % > helps in including the ______ file in the JSP page (Multiple choice)
Skill/Topic: Programming ConstructsA) readOnlyB) dynamicC) staticD) None of the above 

Skill/Topic: Programming ConstructsA) TrueB) False 
Latest Answer : The Bean class which we write has to extend Serializable Interface to make that bean Serialized. The bean itself won't become Serialized automatically.Raghu.  ...


 Sponsored Links

 
Related Articles

List of Popular Scholarship and Grants

List of Popular Scholarship and Grants There are a number of popular scholarships and grants that students will want to look for While obtaining these scholarships can be challenging the rewards are well worth it One of the largest sources of both scholarships and grants is the U S Department of Edu
 

Maintaining Records Within a Data Warehouse

Maintaining Records Within a Data Warehouse If you wish to be successful with your data warehouse it is important for you to make sure you use techniques that will allow you to collect historical information which is related to your company or organization mosgoogle The measurements that you make mu
 

The Importance Of a To-Do List

The Importance Of a To Do List A To Do list is a list of important tasks that you will need to carry out within a given period of time They are a crucial tool for those that want to be skilled at time management The concept of a To Do list is quite simple mosgoogle By having all of the things you ne
 

CSS Tutorials : Lesson 10 : Cascading Style Sheets (CSS) List

CSS Tutorials Lesson 10 List In this tutorial you will learn about Cascading Style Sheets CSS List List style type List style position List style image and Using the shortcut mosgoogle List style type To set the list style marker type use the property list style type&rdquo; this property can
 

Oracle 10g Tutorials - SQL*Loader Discarded and Rejected Records

Oracle 10g Free Training SQL Loader Discarded and Rejected Records In this tutorial you will learn about Discarded and Rejected Records The Bad File SQL Loader Rejects Oracle Database Rejects The Discard File and Log File and Logging Information mosgoogle Discarded and Rejected Records Records read
 

How to List Accomplishments in Your Resume

A resume is practically a list of the things that you have done before you apply for the particular type of job. It will also tell the screener who you are your family background and what you could do for the company. For fresh graduates their resumes are basically a list of things they have done in
 

Report Builder 2.0 - List

The list data region repeats for each row of data. List element provides a single container for the data which can be used to generate what are called Free Form Reports. In this kind of report there is no rigid structure such as a table for the data. You can also place a list inside another list or
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape