• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access xsl variable between pages

 
shanta raja
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a dropdown in the xsl form. When I select a value from the dropdown, I would like to retain the selected value for further calculations, when the onLoad() function is called. I have tried retrieving the selected value using the onchange function and passing it to onLoad(). But the variable does not get passed. I also tried hidden variables, but nothing works. I'm not sure where I'm going wrong. The following is my code

<xsl:template .................................../>
..
..
<script type="text/javascript">
function onLoad() {
alert(document.getElementId('selectedYear').value);
}

function getSelectedYear() {
var yearOptions = document.getElementId('year').options;
selectedYear=yearOptions[yearOptions.selectedIndex].value;
dcoument.mainForm.selectedYear.value = selectedYear;
}
</script>

<table>
<tr>
<td>
<SELECT NAME="year" id="year" onchange="getSelectedYear()">
<!-- xsl:variable attribute name="selectedYear"><xsl:value-of select="year"
/></xsl:attribute>

.
.
</SELECT>

...
...

type="hidden" name="selectedYear" value="{selectedYear}" />

 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First you have to let go of the peculiar concept of an "XSL form". You don't have any such thing. You have -- if I understand your post correctly -- an XSL transformation which generates HTML. And in that HTML you have some Javascript, also generated by the transformation.

Now if I understand your post correctly, you want to pass information from that page (which is HTML, remember) via the form to the next HTML page which is displayed. So when the form is submitted, it has to include that information.

It's impossible to deal with the problem if you only display the XSLT code which generates the page. You have to look at the generated HTML and figure out how to make that HTML do what you need it to do. Then when you have done that, fix the XSLT code to generate HTML which does what you need it to do.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no concept of global state in the eXtensible Stylesheet Language. Only local static variables in a single template element.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic