For each node I also add an image with an onClick method in which I wish to use the same ID as in the text input field...right now I can only set at static ID which always will point to the first iterated element.
My guess is that this has to be re-done in some kind of javascript function and combine it with xslt since the value in the textbox can be changed after the initial load.
Yeah, I'd do it in JavaScript too, using a function like this...
function redirect(href, id) {
var el = document.getElementById(id),
value = el.value;
window.location = href + '?buy=' + id + '&quantity=' + value;
return false;
}
Then in your XSLT part, just reference that function with the reference ID.
getElementById from XSLT
Right now I foreach loop through a set of nodes.
For each iteration I create a textfield with unique ID based on the nodes articleNr value as shown below:
For each node I also add an image with an onClick method in which I wish to use the same ID as in the text input field...right now I can only set at static ID which always will point to the first iterated element.
Ideas?
I'm not sure I understand your question.
However if you are in a loop you can use position to get a unique id?
<input type="text" value="1" size="3"> <xsl:attribute name="id"><xsl:value-of select="articleNr"/><xsl:value-of select="position()"/></xsl:attribute> </input>
Rich
My problem is
<input type="image" onClick="alert(document.getElementById('Here I want to use the same ID as in my previously created textbox').value);"/>
Is the image in the same loop?
Might help if you post your full xslt
Rich
As Rich says, post your XSLT - will give more context. Edit: Opps cross-posted with Fredrik
Try...
Cheers, Lee.
Thanks lee, it worked!
By the way, is there a way to set document.getElementById('{articleNr}').value to a xsl variable?
Hi Fredrik,
Sure, but it will look a bit messy - mostly due to how XSLT mixes up the single/double quotes... but I'd do something like this:
Could probably do it in a single-line using "concat()", but gets tricky trying to escape the single-quotes.
Cheers, Lee.
How about if I want to use what is inside my textbox in a redirect like:
After ?quantity=
My guess is that this has to be re-done in some kind of javascript function and combine it with xslt since the value in the textbox can be changed after the initial load.
Hi Fredrik,
Yeah, I'd do it in JavaScript too, using a function like this...
Then in your XSLT part, just reference that function with the reference ID.
... or something like that! :-)
Cheers, Lee.
Almost here!
I got the output correct in my querystring but it seems like ../nodeName/@id aint passed correctly to the javascript function.
Therefore I end up with, for example;
~/produkter/kemtekniskt/?buy= P704&quantity=5
when it in this case should be
~/produkter/kemtekniskt/aerosoler.aspx?buy= P704&quantity=5
Ahh, think its the inline XPath bit... try this:
Cheers, Lee.
You don't need @nodeName/@id, just @nodeName ( I think!)
Rich
Actually, guessing it needs to be:
Cheers, Lee.
<a href="../{@nodeName/@id}/" onclick="javascript:return redirect(this.href, '{articleNr}');">
´Resulted in
~/produkter//?buy= P708&quantity=14
i need ~/produkter/kemtekniskt/aerosoler.aspx?buy= P708&quantity=14
just @nodeName didnt work either
href="{umbraco.library:NiceUrl(@id)}"
gave me
~/produkter/kemtekniskt/aerosoler/p-700-universalolja.aspx?buy= P700&quantity=1
which is almost here...I just need the parent of p-700-universalolja instead which is aerosoler.aspx
OK... so close!
Cheers, Lee.
it works! Thank you so much!
is working on a reply...