Last active
April 24, 2016 17:54
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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