Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xsl in javascript

 
Nazneen Shaikh
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gotcha...this topic may be closed
Managed it with div's
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic