473,385 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 6730
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dennis Allen | last post by:
Hi. I hope someone here can help. I'm webmaster for a local astronomy club. Just went over our web site. Have validated every htm file on the site except:...
3
by: Bart Van der Donck | last post by:
Hello, I have a dynamic page of which I don't know how many forms will be on it, neither which and how many elements will be in each form. I use the following java script to disable all...
2
by: Jonathan Taub | last post by:
This may seem a stupid question. I've got a <textarea> element: .... <td> List of items: <textarea> 1. Apple 2. Orange 3. Box
16
by: Martin Trautmann | last post by:
Hi all, I just had a problem where Mozilla 1.6 did not accept a XHTML 1.0 page that contained <p><textarea cols="50" name="prod_prob_description" rows="4" /></p> It did not accept the end...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
10
by: Wayne Wengert | last post by:
Is there a way for ASP.NET/VB codebehind to get the contents of a plain old <textarea> element? I added an id='myname' to the <textarea> tag but VSNET complains that it is undefined? Wayne
3
by: FunkHouse9 | last post by:
I'm working on a form to collect data in a textarea which and am trying to keep returns and spaces. I have a couple of functions that I Frankensteined together to replace returns with <br> and to...
7
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
I need to emulate the missing "maxlegth" attribute in "textarea" fields but all my Google searches either lead to obsolete scripts that overwrite the "value" property (thus losing caret position)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.