Hi,
Thank you. That's exactly what i had done.
Regards,
sara
>
>From: "sara" <fillet70@h...>
>Reply-To: "javascript" <javascript@p...>
>To: "javascript" <javascript@p...>
>Subject: [javascript] multicolumn listbox
>Date: Thu, 28 Nov 2002 21:02:24
>
>Is there a way to implement multicolumn list boxes in html ? I browsed the
>web, but could not find any info. on it.
>I dont want to use third party controls. As of now, i'm concatenating the
>fields in my record and displaying them as a string in the listbox.
The only simple way is to use a fixed width font such as Courier New for
the
select box text and pad out fields to be the same width. Let's say you
have
a recordset that returns surname and jobTitle which you now have in an
array:
var arrStaff = new Array(2);
arrStaff[0] = new Array("Simpson", "Doughnut eater");
arrStaff[1] = new Array("Nahasapeemapetilon", "Store keeper");
arrStaff[2] = new Array("Burns", "Power plant owner");
Now you need a function that will pad the strings to a fixed length:
function padString(str, len, char)
{
var sPad = char;
for (var i = 0; i < len - 1; i++)
{
sPad += char;
}
return (str + sPad).substr(0, len);
}
Then use this to get your text values for the select box options:
for (var i = 0; i < arrStaff.length; i++)
{
alert(padString(arrStaff[i][0], 20, " ") + " | " +
padString(arrStaff[i][1], 20, " ") );
}
Hope this helps, as you can see it would help if you knew the longest
string
first to save space and make it appear neater.
Joe
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail