hi respected friends,
i have strucked with out this feature in my project. Please help me,and me sample code if u can .

i have a JSP page which is having two combo boxes,in this page my main aim is:

in my first combo box if i select one courseID ,the next combo box i.e SemesterID need to updated with out page submitting.
I heard that this feature can get by using AJAX and JAVA SCRIPT in JSP.
Here in my data base in course table for example i have 4 course IDs: MTECH
BTECH
MCA
BCA
and
in semester table i have for particular MTECH courseID i have these semesterIDs:sem1
sem2
sem3
sem4

and for MCA courseID i have these semesterIDs:sem1
sem2
sem3
sem3
sem4
sem5
sem6 etc..

here my problem is in my page,in first combo box if i select courseID as: MTECH, in second combobox
i need to get semesterIDs as:sem1,sem2,sem3,sem4.
else if i select courseID as:MCA, in second combo box
i need to get semesterIDs as:sem1,sem2,sem3,sem4,sem5,sem6.


This is the feature i need .
give me sample code for this using AJAX+JAVA SCRIPT in JSP

If these lists are not too long, you would be better off generting a few hidden tags on your form and use pure JavaScript to pull values from the hidden tags to populate your second list. So say your values lists are as follows:

1st List Entry     Values for second list
AAAAA              11111,22222,33333,44444
BBBBB              11111,33333,66666,77777
CCCCC             55555,66666,88888,99999

then you would create 5 hidden tags with the name AAAAA and each one would contain one of the corresponding values. The same for BBBBB and CCCCC.

Then in java script using an onSelect call, you would then populate the second list using the values "hidden" under the same name as the selected value. As long as the lists are not too large, this would be a very good way to solve your problem.

If you still wish to use AJAX, then I would suggest you find some AJAX tutorial sites and get at least a general idea of how AJAX works and how you program it. Then try to do this, and if you have a any specific questions on how to continue find an AJAX and/or JavaScript forum site to ask these questions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.