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>
Related Tutorials/Questions & Answers:
jsp one to one mappingjsp
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 relationshipsHibernate
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 Relationships Hibernate
One-to-
one Relationships
Hibernate
One-to-
one Relationships -
One to
one relationships example
using xml meta-data
This section we
Hibernate one to one mapping using xmlHibernate
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 asOne-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 calledOne-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 ServletTwo 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
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 pageTwo 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 commandcreate .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 thiscan 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
one dimensional array programone dimensional array program Design and implement a java program that will read a file containing numbers and compute the following statistics: the rannge( low, high), the average and the median(middle number).
Notes
Works only for one row Works only for
one row Hi,
My below code is working only if there is a single row. could you please help me in doing it for all the rows retrieved from the database.
<%@page import="java.util.concurrent.CountDownLatch
Hibernate Many One One Mapping between two tables. The
relationship may be
One-To-
One,
One-To-Many, Many-To-
One and Many-To-Many. An
Example of
One To Many mapping is given below
Address... s.address as obj";
Query query = session.createQuery(hql);
List lists
Hibernate One To MappingHibernate
One To
One Mapping Using Annotation
Hi If you are use... annotation
Consider a relationship between a Student and a Address, where
One Student have only
one
Address and an Address is related to only
one student
Hibernate Many-to-one Relationships
Hibernate Many-to-
one Relationships
Hibernate Many-to-
one Relationships - Many to
one relationships example
using xml meta-data
This current
ModuleNotFoundError: No module named 'one-gadget'ModuleNotFoundError: No module named '
one-gadget' Hi,
My Python... '
one-gadget'
How to remove the ModuleNotFoundError: No module named '
one... have to install padas library.
You can install
one-gadget python
ModuleNotFoundError: No module named 'one_nester'ModuleNotFoundError: No module named '
one_nester' Hi,
My Python... '
one_nester'
How to remove the ModuleNotFoundError: No module named '
one... have to install padas library.
You can install
one_nester python
ModuleNotFoundError: No module named 'test_one'ModuleNotFoundError: No module named 'test_
one' Hi,
My Python... 'test_
one'
How to remove the ModuleNotFoundError: No module named 'test_
one... to install padas library.
You can install test_
one python with following
ModuleNotFoundError: No module named 'neater_one'ModuleNotFoundError: No module named 'neater_
one' Hi,
My Python... 'neater_
one'
How to remove the ModuleNotFoundError: No module named 'neater_
one' error?
Thanks
Hi,
In your python environment you
ModuleNotFoundError: No module named 'one-config'ModuleNotFoundError: No module named '
one-config' Hi,
My Python... '
one-config'
How to remove the ModuleNotFoundError: No module named '
one... have to install padas library.
You can install
one-config python
ModuleNotFoundError: No module named 'one-gadget'ModuleNotFoundError: No module named '
one-gadget' Hi,
My Python... '
one-gadget'
How to remove the ModuleNotFoundError: No module named '
one... have to install padas library.
You can install
one-gadget python
ModuleNotFoundError: No module named 'one-line'ModuleNotFoundError: No module named '
one-line' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
one-line'
How to remove the ModuleNotFoundError: No module named '
one-line