Hi i need to create a simple piece of xslt that shows a div only when a text box has some text in it. If the textbox is empty then the div does not show. heres my code:
For some reason the xslt doesnt seem to recognise how many characters the text field has in it. Do i need to add any additional attributes so it recognises this textfield is a datatype? The idea was the iframe would show the webpage specified in the textstring box, if theres nothing in it the iframe would not appear.
As Sebastian is saying it seems like you are missing the $currentPage paramter in your sting-length. However I think you can even just write the following to check if there is a value.
That's not right, now you're checking if the value is not '0'. But you're on the right track, if I had to rewrite this whole code, I'd do it more like this:
character limiting
Hi i need to create a simple piece of xslt that shows a div only when a text box has some text in it. If the textbox is empty then the div does not show. heres my code:
<xsl:template match="/">
<xsl:choose>
<xsl:when test="string-length(data[@alias='linkToASP']) > 0">
<div style="text-align:center;">
<iframe src ="{$currentPage/data[@alias='linkToASP']}" width="810" height="600" scrolling="no" style="border:none;">
<p>Your browser does not support iframes.</p>
</iframe>
</div>
</xsl:when>
<xsl:otherwise>
<div style="text-align:center; display:none;">
<iframe src ="{$currentPage/data[@alias='linkToASP']}" width="810" height="600" scrolling="no" style="border:none;">
<p>Your browser does not support iframes.</p>
</iframe>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Hey Phil, looks like a small mistake to me, you've forgotten $currentPage when you're testing the string-length.
Hi Phil
As Sebastian is saying it seems like you are missing the $currentPage paramter in your sting-length. However I think you can even just write the following to check if there is a value.
<xsl:if test="$currentPage/data [@alias = 'linkToASP'] !='0'">
/Jan
That's not right, now you're checking if the value is not '0'. But you're on the right track, if I had to rewrite this whole code, I'd do it more like this:
Hi Sebasatian
Yes I was typing too fast there. My bad. :-)
/Jan
is working on a reply...