-
Twansparant
Read Text length in ChildNode for autoScroll
Hi everyone,
I'm nearly finished making a website with all of it's content in one xml file.
I have a textbox which reads its content from the xml file with. I'm using a scrollcomponent on the textbox. Now I want to autohide the scrollcomponent if the number of characters is below some number.
How can I read-in the number of text characters in the ChildNode?
PHP Code:
var Desc = project.childNodes[3].firstChild;
detail_mc.description.xmltext.text = Desc;
//Auto Scroll description
if (project.childNodes[3].firstChild.nodeValue >= 10) {
detail_mc.scrolldesc._visible = true;
} else {
detail_mc.scrolldesc._visible = false;
}
If I try this line:
var Desc = project.childNodes[3].firstChild.nodeValue;
The textbox stays empty, so that doesn't work somehow.
Can anyone give me a hand?
Thanks!
-
try
var Desc = String(project.childNodes[3].firstChild.firstChild);
-
http://www.in3d.eu
Hi,
I think the string .length property is what you need..
AS:
PHP Code:
// if "project.childNodes[3].firstChild" is a text node then use
// (for text nodes, the "nodeValue" is a string)
var Desc = project.childNodes[3].firstChild.nodeValue
// if "project.childNodes[3].firstChild" is NOT a text node then use
// var Desc = project.childNodes[3].firstChild.toString()
detail_mc.description.xmltext.text = Desc;
//Auto Scroll description
if (Desc.length >= 10) {
detail_mc.scrolldesc._visible = true;
} else {
detail_mc.scrolldesc._visible = false;
}
// Equivalent to the previous "if" condition is this:
// detail_mc.scrolldesc._visible=(Desc.length >= 10)?true:false
As i wrote in the last line of the previous code, Equivalent to your "if" condition, is this (one) line (use the ternary ? -conditional operator) :
Code:
detail_mc.scrolldesc._visible=(Desc.length >= 10)?true:false
(is not something important, just if want a bit shorter code)
Kostas
Last edited by Kostas Zotos; 06-09-2008 at 01:45 PM.
-
Twansparant
Thanks guys! You were both right!
First I had to make it a string like Cesspenar suggested, and then I could use the Desc.length property like Kostas Zotos suggested.
Thanks a lot!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|