A combo box is a combination text box and select menu, rolled into one. It uses a little known HTML5 element called “datalist”, which is supported by all of the modern browsers, but was never supported by Safari or late versions of Internet Explorer. To set up an HTML5 combo box, start by creating a … Continue reading HTML: How to make a combo box using datalist
JavaScript
JavaScript: How to create a looping tabindex cycle
Let’s say you have a modal with a form in it and you want to have tighter control over what happens when the user uses the Tab button on their keyboard. Without setting controls, it is possible for the user to tab through the text boxes in the modal and change the focus to other … Continue reading JavaScript: How to create a looping tabindex cycle
JavaScript: How to create a custom range slider using bootstrap-slider
This article describes how to create a custom HTML range slider using Bootstrap 3, jQuery, HTML, CSS, and a JavaScript package called “bootstrap-slider”. There are download and installation instructions for this package on github. This slider can be custom styled with CSS and comes with a built-in tooltip. See the graphic below for a description … Continue reading JavaScript: How to create a custom range slider using bootstrap-slider
AngularJS: How to write a simple To Do app
In this article I will describe how to create a simple “To Do” app in AngularJS and write about some of the basic concepts of AngularJS. The app I will be describing looks like this: Step 1: AngularJS CDN To create an AngularJS app, the first thing you will need is a CDN in … Continue reading AngularJS: How to write a simple To Do app
jQuery: How to toggle switches programmatically
Let’s say you have some HTML/CSS switches in place of a traditional checkbox. jQuery makes it easy to toggle switches on or off. For example: function toggle(){ $(‘.slider’).click(); } Which can be called in a button like so: <button type=”button” class=”btn btn-primary” onClick=”toggle();”>Toggle</button> For example: Note: This same jQuery can be triggered without clicking … Continue reading jQuery: How to toggle switches programmatically
JavaScript: How to calculate the number of days between two dates
The following function takes in two dates and returns the number of days between them: // Calculate the difference of two dates in total days function diffDays(d1, d2) { let numDays = 0; let tv1 = d1.getTime(); // msec since 1970 let tv2 = d2.getTime(); numDays = (tv2 – tv1) / 1000 / 86400; numDays … Continue reading JavaScript: How to calculate the number of days between two dates
JavaScript: How to format a number to two decimal places
Let’s say we need to present a number on a web page so that it is always a floating point number with two decimal places. This is for cases where absolute precision is not needed but we want to always present a number output in a uniform way. Here is an example of how to … Continue reading JavaScript: How to format a number to two decimal places
jQuery: How to create an animated alert box
Let’s say you’ve made a login form and you want to display a placard whenever the login information is incorrect to alert the user. For example, when the user types an incorrect email address or password, they see the placard above the form, with a white background and red text: This is easy enough to … Continue reading jQuery: How to create an animated alert box
React: A component render can return only one element!
A component render can return only one element, so if you want more complicated HTML output from your component’s render, it needs to be returned in a single div. In other words, every component can return only a single div. This applies to ReactDOM.render also. So if I want to render a Movie component three … Continue reading React: A component render can return only one element!
React: How to call a parent function from a child function and/or pass data to the parent function
In a continuation of the theme of how to pass information around in react, this article details how to call a parent function from a child function. This previous article details how to pass state from parent to child: React: How to pass state information from parent to child Allowing a child function to call … Continue reading React: How to call a parent function from a child function and/or pass data to the parent function