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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <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); 
        document.getElementById('HtmlCodeID').appendChild(txtNode);
      }
 
      // Taken from http://blog.stevenlevithan.com/archives/faster-trim-javascript
      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);
            break;
          }
        }
        return str;
      }
 
      function removeAllChildren(sElementID)
      {
        var element = document.getElementById(sElementID);
        while (element.firstChild)
        {
          element.removeChild(element.firstChild);
        }   
      }
    </script>
 
 
    <title>Generate html codes to add multiple email addresses</title>
  </head>
 
  <body>
    <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>
    <p>
      Enter emails(Use commas to seperate emails. e.g. my@email.com, your@mail.com):
      <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;" />
    </p>
  </body>
 
</html>
AttachmentSize
HTML icon InviteByEmails.html2.96 KB