WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 string, tom, November 16, 2004
     Re:string , Dave, November 21, 2004
     Re:string, Avner, November 17, 2004
         Re:string, tom, November 17, 2004

Subject: Re:string From: Dave Date: November 21, 2004
I hope the script in this page works in the example area....
From: tom
Sent: November 16, 2004
Subject: Re:string

Does anybody know a way to return strings with different lengths to same length. For now I use this function but aren't happy with it.

function m(str, len) {
  b = '';
 
for (q=0; q<(len-str.length); q++) {
    b += ' ';
  }
 
return str + b;
}

m('tom', 10);      // returns 'tom       '
m('lisa', 10);     // returns 'lisa      '
m('michael', 10);  // returns 'michael   '
m('peter', 10);    // returns 'peter     '

thanx for any help
/tom

Try This:
function m(str, len){
for (; str.length<len; str+=' '){}
return str
}
Example:
alert('|'+
m('
', )+
'|')



Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX