Add multiple emails in "Invite by E-mail address" input field of Facebook's Events

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <script type="text/javascript">
       * Add multiple emails in "Invite by E-mail address" by injecting html code directly in the input form.
       * This script is to generate the html codes.
      function generateHtmlCodes()
        removeAllChildren('HtmlCodeID'); // Clean the output first.
        // Get all commas separated emails addresses.
        var oInputField = document.getElementById('input_field');
        var aEmails = oInputField.value.split(',');
         * For every email, generate html code.
        var sSampleHtml = "<span title=\"xuanngo856\" class=\"removable uiToken\">xuanngo856<input type=\"hidden\" value=\"xuanngo856\" name=\"emails[]\"><input type=\"hidden\" value=\"xuanngo856\" name=\"text_emails[]\"><a href=\"#\" title=\"Remove xuanngo856\" class=\"remove uiCloseButton uiCloseButtonSmall\"></a></span>";
        var sHtml = "";
        for(i=0; i<aEmails.length; i++)
          var sEmail = trim11(aEmails[i]);
          if(sEmail.length > 0)
            sHtml += sSampleHtml.replace(/xuanngo856/g, sEmail);
        // Display the generated html code.
        var txtNode = document.createTextNode(sHtml); 
      // Taken from
      function trim11 (str) {
        str = str.replace(/^\s+/, '');
        for (var i = str.length - 1; i >= 0; i--) {
          if (/\S/.test(str.charAt(i))) {
            str = str.substring(0, i + 1);
        return str;
      function removeAllChildren(sElementID)
        var element = document.getElementById(sElementID);
        while (element.firstChild)
    <title>Generate html codes to add multiple email addresses</title>
    <h1>Add multiple emails in "Invite by E-mail address" input field of Facebook's Event system by injecting html codes directly in the input form.</h1>
    <h3>This script is to generate the html codes.</h3>
      Enter emails(Use commas to seperate emails. e.g.,
      <input type="text" id="input_field" style="width:100%;"/><br />
      <button onclick="generateHtmlCodes()">Generate</button>
      <pre id="HtmlCodeID" style="background-color: #C0C0C0; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;" />
HTML icon InviteByEmails.html2.96 KB