cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <form name="names">
  <input type="text" id="box1" name="firstlastname" placeholder="Luke Skywalker"><br>
  <input type="text" id="box3" name="domain" placeholder="disney.com"><br>
  <input type="text" id="box2" name="sep" placeholder="Optional: custom separator"><br>
  <input type="submit" id="button-make" value="Make Variations" onClick="permutate(this.form);return false;">
</form>

<input type="submit" id="button-reset" value="Reset" onClick="reset('results');return false;">

<div id="results"></div>


            
          
!
            
              #form{
  margin-top: 20px;
}

input[type]{
  font-size: 25px;
  font-family: arial;
}

#box1, #box2, #box3{
  width: 317px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid rgb(200,200,200);
  border-top-color: rgb(100,100,100);
  border-radius: 5px;
  color: #5A5A5A;
}

#button-reset{
  position:relative;
  display:inline-block;
}

#button-make, #button-reset{
  float:left;
}

#button-reset{
  margin: 0 0 0 10px;
}

#results{
  position: relative;
  display: block;
  overflow: auto;
  margin-top: 45px;
  padding: 15px;
  border: 1px solid rgb(200,200,200);
  /*border-bottom: 1px solid rgb(200,200,200);*/
  background: rgb(245,245,245);
  color: rgb(50,50,50);
  font-size: 20px;
  line-height: 36px;
  font-family: arial;
}
            
          
!
            
              function permutate(form) {

  var firstlastname = form.firstlastname.value.toLowerCase().trim();
  var namesplit = firstlastname.split(" ");
  var firstname = namesplit[0];
  var lastname = namesplit[1];
  var domain = form.domain.value.toLowerCase().trim();
  var sep = form.sep.value + ' ';
  //var sep = ", ";
  
  if (firstname==null || firstname==""){
    document.getElementById("results").innerHTML= "Please provide a first name e.g. Luke";
    return false;    
  } else if (lastname==null || lastname==""){
    document.getElementById("results").innerHTML= "Please provide a last name e.g. Skywalker";
    return false;    
  } else if (domain==null || domain==""){
    document.getElementById("results").innerHTML= "Please provide a domain e.g. yahoo.com";
    return false;
  } else {}
  
  //If no optional separator, defult to comma
  if (sep==null || sep==" "){
    sep = ", ";
  }
  
  //bob@domain.com
  var p1 = firstname + "@" + domain + sep;
  
  //bobsmith@domain.com
  var p2 = firstname + lastname + "@" + domain + sep;
  
  //bob.smith@domain.com
  var p3 = firstname + "." + lastname + "@" + domain + sep;
  
  //smith@domain.com
  var p4 = lastname + "@" + domain + sep;
  
  //bsmith@domain.com
  var p5 = firstname.charAt(0) + lastname + "@" + domain + sep;

  //b.smith@domain.com
  var p6 = firstname.charAt(0) + "." + lastname + "@" + domain + sep;
  
  //bobs@domain.com
  var p7 = firstname + lastname.charAt(0) + "@" + domain + sep;
  
  //bob.s@domain.com
  var p8 = firstname + "." + lastname.charAt(0) + "@" + domain + sep;
  
  //bs@domain.com
  var p9 = firstname.charAt(0) + lastname.charAt(0) + "@" + domain;
  
  var addresses= p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;
  
	document.getElementById("results").innerHTML= addresses;
}

function reset(results) {
  document.getElementById("results").innerHTML= "";
  document.getElementById("box1").value = "";
  document.getElementById("box3").value = "";
  document.getElementById("box2").value = "";
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console