[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2008-11-14
13
Medium Priority
?
1,223 Views
Last Modified: 2013-11-18
How to change the value of a <xsl: with-param > Value through JavaScript?
0
Comment
Question by:Chamarthi
  • 6
  • 4
11 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22958214
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
0
 

Author Comment

by:Chamarthi
ID: 22958217
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
0
 

Author Comment

by:Chamarthi
ID: 22958250
>>>>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?

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22958315
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

0
 

Author Comment

by:Chamarthi
ID: 22958430
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?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22958458
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
0
 

Author Comment

by:Chamarthi
ID: 22958465
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.
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 1000 total points
ID: 22958494
well,
I don't think that you understand what I need.

in your template call, you have a with-param name="label"
This will finally result in a HTML construct.
I NEED to know where in the resulting HTML the $label will be put, in order to address that with a DOM construct in your JavaScript
For that I NEED to see what is in the XSLT named template,
so can you please post the XSLT snippet starting with
<xsl:template name="Button">
... and ending with ...
</xsl:template>

Thank you
Geert
0
 
LVL 4

Assisted Solution

by:pellep
pellep earned 1000 total points
ID: 22959021
Looks to me like you're going at it a bit backwards. The XSLT would be processed by the browser when it loads the page. Once the page is loaded, any javascript you execute will only interact with the actual DOM of the page that was the result of the XSL transformation. Modifying the XSLT after the fact really doesn't make sense.

From what I can read from your posts, you're looking to modify the label of a button, for which there is no need to mess with the XSLT. Just modify the property in the DOM model directly (like you proposed in your last post above).

document.getElementById('modelButtonClickOk').value='Submit';
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22959183
@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 :-(
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24011617
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
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question