/* hw3b.js */
/*-------------------------------------------------------------------------------------------------
PASSWORD
-------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------
Counting Bio Characters max of 140
-------------------------------------------------------------------------------------------------*/
var maxChars = 140;
var bioInput = document.getElementById("bio");
var c = document.getElementById("charsLeft");
c.innerHTML = maxChars;
// All we need is events, the length property, and writing
// to the DOM to make a counter
bioInput.addEventListener("keyup", charsLeft);
function charsLeft(e) {
var len = bioInput.value.substring(0, 139).length;
//console.log(len);
if (len >= maxChars) {
console.log(maxChars);
e.preventDefault();
} else {
c.innerHTML = maxChars - len-1;
}
}
/*-------------------------------------------------------------------------------------------------
SELECT LIST
-------------------------------------------------------------------------------------------------*/
/* First, populate the select.
For each element in the "selectList.fruits" array,
we will create an <option> element, give it a
text node that contains its label, set the
'value' attribute on our new <option> element, and
finally, add it to the <select> element.
*/
var sel1 = document.getElementById("firstSelect");
var sel2 = document.getElementById("secondSelect");
var selectList = {
"chains": ["rice", "snake", "omega", "neoprene"]
}
//var riceLength =
for (var i = 0; i < selectList.chains.length; i++) {
//create <option>
var s = document.createElement("option");
//create text node
var t =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.