franco32
asked on
Using AJAX to auto-load 4 <select> boxes
I've implemented AJAX to auto-load 4 different <select> tags. The 1st 3 work fine, but failing on the 4th.
I have the following in my JSP page:
<td>
<select id="cat" id="cat" onChange="loadarea(this.se lectedInde x);">
<option></option>
</td>
<td>
<select id="area" id="area" onChange="loadsection(this .selectedI ndex);">
<option></option>
</td>
<td>
<select id="section" id="section" onChange="loaddetail(this. selectedIn dex);">
<option></option>
</td>
<td>
<select id="detail" id="detail" >
<option></option>
</td>
The loadarea, loadsection and loaddetail are pretty much the same. I'm simply pulling the user selected data and passing that to the servlet to get the data to preload the appropriate <select> boxes.
The AJAX works great on loading the "AREA" and "Section" tags, but failing on the "Detail". I've verified the servlet that fetches the detail data works fine.
The javascript function "loaddetail looks like:
var area1;
var section1;
var cat1;
function loaddetail(i)
{
section1 = document.getElementById("s election") ;
var url="SelectDetail?cat=" + cat1.value + "&area-" + area1.value + "§ion=" + escape(section1.options[i] .text);
NOTE: The value "area1" is "false". Not sure why, so subsequently the servlet "SelectDetail" does not return any data.
}
I can provide more details if necessary. Just puzzled why the pre-load of the 4th text box fails.
Thanks!
I have the following in my JSP page:
<td>
<select id="cat" id="cat" onChange="loadarea(this.se
<option></option>
</td>
<td>
<select id="area" id="area" onChange="loadsection(this
<option></option>
</td>
<td>
<select id="section" id="section" onChange="loaddetail(this.
<option></option>
</td>
<td>
<select id="detail" id="detail" >
<option></option>
</td>
The loadarea, loadsection and loaddetail are pretty much the same. I'm simply pulling the user selected data and passing that to the servlet to get the data to preload the appropriate <select> boxes.
The AJAX works great on loading the "AREA" and "Section" tags, but failing on the "Detail". I've verified the servlet that fetches the detail data works fine.
The javascript function "loaddetail looks like:
var area1;
var section1;
var cat1;
function loaddetail(i)
{
section1 = document.getElementById("s
var url="SelectDetail?cat=" + cat1.value + "&area-" + area1.value + "§ion=" + escape(section1.options[i]
NOTE: The value "area1" is "false". Not sure why, so subsequently the servlet "SelectDetail" does not return any data.
}
I can provide more details if necessary. Just puzzled why the pre-load of the 4th text box fails.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
(e.g).
CATEGORY AREA SECTION DETAIL
CAT1 AREAx
AREAy
AREA1 Section3
Section3a
Section3b detailb
Once the user selects CAT1 from category, AREAx,AREAy,AREA1 are displayed in the next <select>. If the user selects AREA1, Section3,Section3a,Section
Hope I clarified that.
Thanks.