This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes xsl in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "xsl in javascript" Watch "xsl in javascript" New topic
Author

xsl in javascript

Nazneen Shaikh
Greenhorn

Joined: May 01, 2003
Posts: 21
Hi,

I am currently working on xsl/xml. I have to implement 2 related dropdown select boxes. I get the data as a jdbc resultset which i can very easily parse with <xsl:for-each> consruct. I want to use this in the javascript so that when ever i call the onchange method from the country drop-down the state drop-down will be re-populated with states of the country selected.

i need to implement something like this

<script>
var selcountry=doc.form.selCountry.value;
<xsl:for-each>
when xsl of statecountry=selcountry
<option>state</option>
</xslfor-each>
</script>


Pls tell me how can i do it, and the syntax for the same please.....
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
problem is the xsl is fired before the page is loaded so you would have to reload the page to fill in the second list. You may want to look into an Ajax solution where you can use a transformation, get the values and fill it in.

Eric
Nazneen Shaikh
Greenhorn

Joined: May 01, 2003
Posts: 21
Hi,

I have managed to get the country and states in two different array, and have a a javascript to populate the state select on the basis of the selected country.
The problem that i am facing now is since on page load, the state select box is not populated with any of the states but a default value of "select state" after i have submitted the page and i go to the next page, if from the next i try to come back(history.go(-1)) the value of the state selected earlier is lost, the list is not populated though the country is selected, i get the populated state list, I need to select a different country and then re-select the original one
please help.
I tried putting in a hidden field, and i am storing the value of the selected state ithis hidden field and i am trying to put in a javascript on the basis of that, but even this hidden field value is reset to null on back.
Please help
Thanking in advance
Naz
Nazneen Shaikh
Greenhorn

Joined: May 01, 2003
Posts: 21
gotcha...this topic may be closed
Managed it with div's
 
jQuery in Action, 2nd edition
 
subject: xsl in javascript
 
Similar Threads
javascript: onload function with xsl
jsp drop down list problem
XSL/JavaScript question & XSL question
Strut-Ajax - display states when Country selected
mouse hover on multiselect dropdown