473,769 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6785
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(s tring-length(//descr1) div 40) &lt; 4">
<xsl:attribut e name="rows">4</xsl:attribute>
</xsl:when>
<xsl:otherwis e>
<xsl:attribut e name="rows"><xs l: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|d escr2|descr3">
<xsl:choose>
<xsl:when test="ceiling(s tring-length(.) div 40) &lt; 4">
<xsl:attribut e name="rows">4</xsl:attribute>
</xsl:when>
<xsl:otherwis e>
<xsl:attribut e name="rows"><xs l: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
4327
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: http://validator.w3.org/check?uri=http://www.stargazing.net/mas/COMET.htm In the <textarea> of this page I have Javascript code. I can't figure out how to present this code and still be w3c valid. Any advice would be appreciated...Dennis
3
7186
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 elements from all forms: var numberForms = document.forms.length; var formIndex;
2
9268
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
2921
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 tag />, but selected everything after til the EOF as text within the textarea.
11
13725
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, there's an "Edit" link. So the page itself looks something like this: <HTML><HEAD><TITLE>blah</TITLE></HEAD><BODY> <!-- TEXT STARTS HERE --> <H1>Hello World!</H1> <P>More stuff here...</P>
10
3907
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
5671
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 replace spaces with &nbsp;. The <br> part works well enough, but I keep getting "%20" instead of "&nbsp;" for the spaces. I understand that escape() changes " " to "%20", but I would think the ConvertSpaces function below would change the %20 to...
7
3113
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) or to complex solutions that work on top of specific frameworks. Do you have some reference on how to do it? I'd like to make it work in at least Firefox and IE 6 and 7. Thank you in advance,
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.