Validate 2 list boxes, one is multiselect, one is singleselect
<head>
<script language="javascript">
function validateListBox(){
var lb = document.getElementById('mySelect');
var count1 = 0;
arrTexts = new Array();
for(var i=0; i<lb.length; i++) {
if(lb[i] != 0){
count1++;
}
}
if(count1 != 0){
alert('empty');
return true;
}
return false;
}
</script>
<noscript>Your browser does not support JavaScript!</noscript>
</head>
One list box contains "student" IDs, and the other one contains "courses" IDs. I want the user to assign students to courses by selecting the corresponding IDs and I will enter the user's input into a bridge table. This bridge table links between "students"-"courses".
I want to restrict the user to choose 1 student-> to 1/more courses per form entry. NOT many students-> 1/many courses.
I've seen on Google that function must be call with onClick, other said with onSubmit. And many examples but none worked for me.
In the form I call it as so:
<form action = "AssignmentsList.jsp" method="post" name="entry">
.................
<input type="button" value = "Link" onClick = "validateListBox()"/>
.................
View Answers
July 22, 2012 at 11:19 PM
I finally find out to be:
<script language="javascript">
function validate(){
var k=0;
if (entry.elements["sid"].selectedIndex == -1) {
k++;
alert('You cannot select one side only');
return false;
}
if (entry.elements["cid"].selectedIndex == -1) {
k++;
alert('You cannot select one side only');
return false;
}
if(k == 0){
return true;
}
return false;
}
</script>
Ads
Related Tutorials/Questions & Answers:
jsp one to one mapping
jsp
one to
one mapping how to perform
one to
one mapping in jsp....code of
one to
one mapping with .xml file
Advertisements
Hibernate one-to-one relationships
Hibernate
one-to-
one relationships How does
one to
one relationship work in Hibernate?
Hibernate Mapping
One-to-
One
Hibernate provides.... here is an example showing
one to
one relationship using hbm.xml.
We have two
Give a one to one example in Hibernate.
Give a
one to
one example in Hibernate. Hello,
Can you give me
one to
one example in Hibernate..Thanks....
Hello,
TO read about
One to
one relationships in hibernate, you can go through the following links
JPA One-to-One Relationship
JPA
One-to-
One Relationship
 ... will learn about the
one-to-
one
relationship. In the
one-to-
one relation mapping a single value association
to another entity.
One-to-
One: In
one-to-
one
Hibernate one to one mapping using xml
Hibernate
one to
one mapping using xml Hi,
How to create hibernate
one to
one mapping using xml? I have to create the mapping using the *.hbm.xml...,
In case of
one-to-
one mapping for each reach in a table there is corresponding only
What is Hibernate one to one relation?Any example..
What is Hibernate
one to
one relation?Any example.. Hello,
What is Hibernate
one to
one relation? Is there any example of it..
Thanks..
Dear Friend,
Here are detailed tutorials and examples of Hibernate
One-to-
one
One-Millionth of a second is referred as
One-Millionth of a second is referred as
One-Millionth of a second is referred as -?
1. Microsecond
2. Millisecond
3. Hour
4. Minute
5. All of the above
Answer: 1. Microsecond
One-thousand of a second is called
One-thousand of a second is called
One-thousand of a second is called-
1. Microsecond
2. Millisecond
3. Hour
4. Minute
5. All of the above
Answer: 1. Microsecond
Two forms and One Servlet
Two forms and
One Servlet Dear Sir,
I have
2 forms in
one page and
one submit button into second form which submits data to
one servlet.
If I do request.getparameter("") from first form textbox name I got null value.
How do I
Hibernate One-to-one Relationships
Hibernate
One-to-
one Relationships
Hibernate
One-to-
one Relationships -
One to
one relationships example
using xml meta-data
This section we
ModuleNotFoundError: No module named 'one'
ModuleNotFoundError: No module named '
one' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
one'
How to remove the ModuleNotFoundError: No module named '
one' error
Two Pagination in one page
Two Pagination in
one page hai friends any
one help me.
how do u make two pagination script in same page i'm used some ajax coding
one pagination script is working but another pagination is not working please help me urgent
create .tar.gz in one command
create .tar.gz in
one command Hi,
I have a big file on Linux server and I want to crate the tar.gz file so that size can be reduced and taken for backup.
I want the command to that i can create .tar.gz in
one command.
Give me
can any one explain this
can any
one explain this class Clidder {
private final void flipper() {
System.out.println("Clidder");
}
}
public class Ex3 extends Clidder {
public final void flipper() {
System.out.println
Resultset with one to many relationship
Resultset with
one to many relationship Suppose there are 5 tables in database named A,B,C,D and E. A has
one to many relationship with B,C,D and D has
one to many relationship with E. Beam class of A contains array of Class B