Link to home
Start Free TrialLog in
Avatar of Chamarthi
Chamarthi

asked on

How to change the value of XSL with-param value through JavaSCript

How to change the value of a <xsl: with-param > Value through JavaScript?
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

I can imagine that you want to change a value from an xsl:param whilst calling your XSLT from javascript
For that you need a template processor and use addParameter
The xsl:param also needs to be global to the stylesheet then

If that is not what you want, I need more info on what you exactly want to do... and why.
Inside a stylesheet, javascript would only work in msxml and xalan as a processor

so... more info please
Avatar of Chamarthi
Chamarthi

ASKER

Hello Experts..
My Code is like this...
<td id="ModelButtonOK">
        <xsl:call-template name="Button">
               <xsl:with-param name="label" select="Ok" />
               <xsl:with-param name="id" select="modelButtonClickOk" />
        </xsl:call-template>
</td>

Now I want to read the parameter Name 'label' and change the value to 'Submit' in JavaScript..
Please pass any information on how to do this? Please send me a Hint...

Thanks,
Varma
>>>>Inside a stylesheet, javascript would only work in msxml and xalan as a processor
  Not inside of the xsl. I am getting the id of getElementById('ModelButtonOK'). How can I traverse the sibblings of this parent node? and How can I get the name of the <label> and change the vale?
May be this is a basic question. Please provide any information?

So, this clarifies your question quiet a bit.
(I hope you understand that your original question was lacking crucial information)

Can you now show me how that you call the XSLT?
I assume you are having browser JavaScript (some sort of AJAX) or that you are doing this in ASP

I don't recommend that you change the XSLT using DOM methods.
I strongly recommend that you pass the value as a paramameter to the XSLT, as I suggested in my first comment

you would then have a param at the top level of your stylesheet
<xsl:param name="model_button_label"/>

and use it like this

<td id="ModelButtonOK">
        <xsl:call-template name="Button">
               <xsl:with-param name="label" select="$model_button_label" />
               <xsl:with-param name="id" select="modelButtonClickOk" />
        </xsl:call-template>
</td>

in order to help you with that, I need to know where the JavaScript is and have to see it

cheers

Geert

I am writing the browser javascript and I am calling it directly from the xsl. have a look at below...

<xsl:attribute name="onclick">
<xsl:text>js.showModelDialog(some parameters)</xsl:text>
</xsl:attribute>

Now in the same xsl file i have declared the
<td id="ModelButtonOK">
        <xsl:call-template name="Button">
               <xsl:with-param name="label" select="Ok" />
               <xsl:with-param name="id" select="modelButtonClickOk" />
        </xsl:call-template>
</td>
...
In JavaScript
function showModelDialog()
{
 var okButton = document.getElementById(ModelButtonOK);
var okButton = document.getElementById(modelButtonClickOk);
//here I want to write a code to get the 'label' value and chnge it to 'Submit'

}
Hope you got the necessary information?
well, you are not winning a prize for being accurate in your question :-(

So, basically you are constructing the browser javascript in your XSLT?
Is that correct???

Now we are getting somewhere.
Your original question has put me on the wrong foot.

There is no need to change the with-param, but the resulting button...
(the with-param will be gone in the resulting HTML, all that is left is the pure HTML/javascript)

what is in the named template "Button"?
I need to see the XML snippet that says
<xsl:template name="Button">
...

thanks

Geert
I am looking for similar to like this..

Example: if you a HTML form..
<html>
<body>
 <input type=button name='mybutton" value="OK" onclick="callMe()">
</body></html>
<script type="javascript">
function callMe(){
      document.myform.mybutton<b>.value = "Submit";</b>

}
</script>

I want to just change the value of the button dynamically.
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@pellep
I came to a similar conclusion.
Your code would be OK, if his named template indeed would simply create a simple button
that is why I was waiting for having acces to the named template :-(
I hate it when they do this ....
we are actually waiting for feedback from OP, lot of effort has gone in this question,
if the OP does not answer within the time given, close the question like this please
split
gertone: 22958494
pellep: 22959021