Wednesday, October 04, 2006

Blogger Beta all labels selection

This is my first post, I'm more of a coder than a writer but I'll try to (etc2x) what's in my mind.

You can always, post comment with your suggestions and recommendations. Just don't give me a wild reaction.

Now lets go to the Code Sample part.

The script below will mimic the experience when you click a label in the All Labels section of blogger when you create a post. Call the script passing the label/tag.

Example

toggleTag('Scoters')

or


<a href="javascript:toggleTag('vacation');void(0);">vacation</a>


THE CODE

function toggleTag(sTag)
{
var eTags = "Get reference to your label input object";
if (eTags != null)
{
// Search if tag is already in the list if not add
var sOldTags = ';' + eTags.value.replace(/; /g,';') + ';';
if (sOldTags != ';;')
{
if (sOldTags.toLowerCase().match(';' + sTag.toLowerCase() + ';') == null)
{
var sNewTags = sOldTags.replace(/;/g,'; ') + sTag;
eTags.value = sNewTags.substr(2);
}
}
else
{
eTags.value = sTag;
}
}
}


a s t a l a v i s t a

No comments: