Skip to content

Instantly share code, notes, and snippets.

@davidlwatsonjr
Last active April 24, 2016 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidlwatsonjr/9b8d1068b5fa9b1ba8129306745b369e to your computer and use it in GitHub Desktop.
Save davidlwatsonjr/9b8d1068b5fa9b1ba8129306745b369e to your computer and use it in GitHub Desktop.
A really dumb telephone input inspired by https://i.imgur.com/C0H0fIX.jpg
<link rel="import" href="//polygit.org/components/polymer/polymer.html" />
<dom-module id="dumb-telephone-input">
<template>
<select id="area"></select>
<select id="prefix"></select>
<select id="phone"></select>
</template>
</dom-module>
<script>
(function(dlwj){
dlwj.DumpTelephoneInputElement = Polymer({
is: 'dumb-telephone-input',
properties: {},
ready: function() {
var i, iString, option;
var areaCode = Polymer.dom(this.$.area);
var prefixCode = Polymer.dom(this.$.prefix);
var phoneNumber = Polymer.dom(this.$.phone);
for (i = 0; i < 1000; i++) {
iString = "" + i;
option = document.createElement('option');
option.value = "000".substring(0, 3 - iString.length) + iString;
option.textContent = option.value;
areaCode.appendChild(option);
}
for (i = 0; i < 1000; i++) {
iString = "" + i;
option = document.createElement('option');
option.value = "000".substring(0, 3 - iString.length) + iString;
option.textContent = option.value;
prefixCode.appendChild(option);
}
for (i = 0; i < 10000; i++) {
iString = "" + i;
option = document.createElement('option');
option.value = "0000".substring(0, 4 - iString.length) + iString;
option.textContent = option.value;
phoneNumber.appendChild(option);
}
}
});
}(window.davidlwatsonjr = window.davidlwatsonjr || {}));
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment