Click to See Complete Forum and Search --> : Urgent help:XML-Servlet-Javascript Dropdown COnfusion


desigabru
03-01-2006, 01:04 PM
Hi there,

I am having a lot of problems in figuring out this latest problem at my work place.

Firstly we had a servlet which would fetch data from an XML file using tag names and present them into different drop downs.

But now the latest requirement is to make the drop down dynamic..as in the 2nd drop down content depend on the first one and the thrid one on the second one.

I am not sure how would i write a Javascript file and call it from my servlet sending the XML data to it.(Basically i am not sure how to accomplish the new requirement)

Please help...as i need to get this done asap

thankssss :confused:

Khalid Ali
03-01-2006, 02:49 PM
your question is more like for Java server side code...I am moving it to Java forums.
Now to answer ur question. You will need to let us know the complete events cycle for what happens when the page displays the first listbox, what constitutes the second and 3rd listboxes and where the information comes from etc.

desigabru
03-01-2006, 03:06 PM
Hey Khalid,

See the problem lies here..

there are 4 drop downs.
the way i am gettin the XML

<PermitYear>
2004
<SubYears>
<SubYear>
2
<UnitCds>
<UnitCd>
011400706
<Lots>
<Lot>L </Lot>
</Lots>
</UnitCd>
</UnitCds>
</SubYear>
</SubYears>
</PermitYear>
</PermitYears>
and there can be more like this


1st one shows the list of permit years-2004,2006 (all this data has to be populated dynamically -I am getting all this data in XML )-The 2nd,3rd,4th box dont show anything

once the user selects a value from the first drop down , the 2nd drop down shows the corresponding values.once the second drop down value is selected the third one is updated accordingly.

I was thinking of sending a r4equest to the server every time a user selects one value from the drop downs...but my boss dosent want it that way...

so here i have a servlet which is getting the xml data from their mainframe program...and i need to send it to another JS program which processes it in a such a way that i get these drop downs dynamically...hope that helps...

desi

Khalid Ali
03-01-2006, 03:22 PM
well u still did not mention that where is the data come from that u use in send third etc listboxes

desigabru
03-01-2006, 03:29 PM
FIRST RECORD
<PermitYear>
2004 //First List Box
<SubYears>
<SubYear>
2 //2nd List Box
<UnitCds>
<UnitCd>
011400706 //3rd List Box
<Lots>
<Lot>L </Lot>
<Lot>G </Lot> //All the Lots in the 4th List box
<Lot>F </Lot>
</Lots>
</UnitCd>
</UnitCds>
</SubYear>
</SubYears>
</PermitYear>
</PermitYears>

SECOND RECORD
<PermitYear>
2006 //First List Box
<SubYears>
<SubYear>
3 //2nd List Box
<UnitCds>
<UnitCd>
011400706 //3rd List Box
<Lots>
<Lot>L </Lot>
<Lot>G </Lot> //All the Lots in the 4th List box
<Lot>F </Lot>
</Lots>
</UnitCd>
</UnitCds>
</SubYear>
</SubYears>
</PermitYear>
</PermitYears>

So once the person selects one the permit year (2004 ,2006)..the second list box gets populated by the corresponding Sub Year.and so on and so forth...

thx for the prompt response khalid...

desi

Khalid Ali
03-01-2006, 03:39 PM
I take it you have no problem parsing XML doc using JavaScript? if this is the case and you only need to know the JavaScript bit that will display something along those lines.
here is the link where I have a solution for such purpose (http://www.webapplikations.com/pages/html_js/forms/DropDownSelectCountryShowCities.html).
However if you need logic how to go about doing this then here is what I can think of right away.

1. create as many arrays as many listboxes u need (3?)
2. read xml document
3. read the first listboxes values all of them in the array
4. read the second listboxes all values in the second array and so on.
5. then go to the url above and see how the actual functionality is done.
Hope this helps and puts u on right path...:-)

Cheers
P.S now that I see ur question, its not related to Java....

desigabru
03-01-2006, 03:47 PM
thx khalid...but I am not sure i kno how to parse XML doc using JavaScript??? :-(

desigabru
03-01-2006, 03:48 PM
and also the xml is coming thru a servlet and then being parsed by the javascript..

Khalid Ali
03-01-2006, 06:26 PM
u know Java? or anything about programming(even JavaScript)?

desigabru
03-01-2006, 07:19 PM
I know java ..I have mainly worked on servlets...but not javascript

chazzy
03-01-2006, 10:07 PM
If you need to dynamicly parse the XML when the client's selecting things in drop downs, you'll need to use javascript's XML parsing. Otherwise, you need to use Java. What approach are you using?

desigabru
03-02-2006, 03:01 PM
I am trying to use javascript's XML parsing but not successful till now...some sort of code would be helpful

Thanks Chazzy

desi

chazzy
03-02-2006, 07:56 PM
Do you have some code that you've already built then? This is the Java forum, not Javascript. ;)