...

View Full Version : how to change the length of a string



sybil6
03-16-2009, 11:48 PM
i have a xml file where i do the following query:


entry_03_title=doc.documentElement.getElementsByTagName("entry")[2].getElementsByTagName("title")[0].firstChild.data;

now having the variable "entry_03_title" i would like that javascript do this:


if(entry_03_title.length>30) entry_03_title.length=6

in other words if the title is bigger than 30 chars long make it 6 chars, but this doesn't work.any thoughts?

Old Pedant
03-16-2009, 11:50 PM
if(entry_03_title.length > 30) entry_03_title = entry_03_title.substring(0,6);

Maybe time to download a JavaScript reference manual? There are a few good ones out there.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum