By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,650 Members | 1,785 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,650 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/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)

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

P: n/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="/">
...
<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

P: n/a


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.