469,282 Members | 2,034 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

how to set height of <textarea> element dynamically using xslt?

hi all,
in xml file I have some fields which are source for <textarea> element.
I'd like to transform this file using xslt and set the rows property of
<textarea> depend of lines in some source field.
How to do this?

regards
jaro
Nov 12 '05 #1
3 6407
Jarek Mielcarek wrote:
in xml file I have some fields which are source for <textarea> element.
I'd like to transform this file using xslt and set the rows property of
<textarea> depend of lines in some source field.
How to do this?


Height is a visual property and as such is really hard to calculate. You
better set rows and cols properties according to number of characters
the textarea contains. Something like
rows = ceiling(string-length($content) div $cols)

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
Oleg Tkachenko [MVP] napisał(a):
Jarek Mielcarek wrote:
in xml file I have some fields which are source for <textarea> element.
I'd like to transform this file using xslt and set the rows property
of <textarea> depend of lines in some source field.
How to do this?

Height is a visual property and as such is really hard to calculate. You
better set rows and cols properties according to number of characters
the textarea contains. Something like
rows = ceiling(string-length($content) div $cols)


thx for help. it works when I do something like this:
<xsl:template match="/">
...
<textarea id="descr1" cols="40">
<xsl:choose>
<xsl:when test="ceiling(string-length(//descr1) div 40) &lt; 4">
<xsl:attribute name="rows">4</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="rows"><xsl:value-of
select="ceiling(string-length(//descr1) div 40)+1" /></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="//descr1" />
</textarea>
....
</xsl:template>

but it doesn't set row property in this sample:

<xsl:template match="/">
...
<textarea id="descr3" cols="40">
<xsl:apply-templates select="/document/descr3"/>
</textarea>
....
</xsl:template>

<xsl:template match="descr1|descr2|descr3">
<xsl:choose>
<xsl:when test="ceiling(string-length(.) div 40) &lt; 4">
<xsl:attribute name="rows">4</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="rows"><xsl:value-of
select="ceiling(string-length(.) div 40)+1" /></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="." />
</xsl:template>

the question is why?
jaro
Nov 12 '05 #3


Jarek Mielcarek napisał(a):
Oleg Tkachenko [MVP] napisał(a):
Jarek Mielcarek wrote:
in xml file I have some fields which are source for <textarea> element.
I'd like to transform this file using xslt and set the rows property
of <textarea> depend of lines in some source field.
How to do this?


Height is a visual property and as such is really hard to calculate.
You better set rows and cols properties according to number of
characters the textarea contains. Something like
rows = ceiling(string-length($content) div $cols)


thx for help. it works when I do something like this:
<xsl:template match="/">
..

-- cut --

ok, everything works fine now. For test purpose I use short strings with
CrLf and thats why rows calculating was wrong.
thx again
jaro
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Dennis Allen | last post: by
3 posts views Thread by Bart Van der Donck | last post: by
2 posts views Thread by Jonathan Taub | last post: by
16 posts views Thread by Martin Trautmann | last post: by
11 posts views Thread by Les Paul | last post: by
10 posts views Thread by Wayne Wengert | last post: by
7 posts views Thread by =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.