<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: rjdoughty</title>
    <description>The latest articles on DEV Community by rjdoughty (@rjdoughty).</description>
    <link>https://dev.to/rjdoughty</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F110350%2Fb31e627f-02bb-4a7c-82ed-bb0d092ed970.png</url>
      <title>DEV Community: rjdoughty</title>
      <link>https://dev.to/rjdoughty</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rjdoughty"/>
    <language>en</language>
    <item>
      <title>Getting in the Node</title>
      <dc:creator>rjdoughty</dc:creator>
      <pubDate>Sun, 02 Dec 2018 00:43:56 +0000</pubDate>
      <link>https://dev.to/rjdoughty/getting-in-the-node-2l8e</link>
      <guid>https://dev.to/rjdoughty/getting-in-the-node-2l8e</guid>
      <description>&lt;p&gt;I have written blogs about using html to create inputs and using JavaScript and jQuery to take in the inputs from the user.  So my next topic is what happens to values from the inputs.  In order to expand on that thought, I have to think about how important Node.js is to web development.&lt;/p&gt;

&lt;p&gt;Node.js is an application that enhances the capabilities of JavaScript.  JavaScript is only capable of being run in a browser to make web pages interactive.  Node.js can be run without a browser as a standalone application.   JavaScript is like a train in that it can only be driven on train tracks.  Node.js converts the JavaScript train so that it can be driven on the road.  This creates many more possibilities.  &lt;/p&gt;

&lt;p&gt;The biggest use of Node is as a basis for web servers.  A web server takes a client request and gives something back such as a new web page, text information or content.   &lt;/p&gt;

&lt;p&gt;Thanks to some great coders, there are packages already available that can be included in applications to create web servers. Node.js uses npm (Node package manager) which has packages that will make development faster and better.  Require loads the libraries installed from npm.  Node modules are built in modules that are automatically installed. &lt;/p&gt;

&lt;p&gt;Packages are created by entering commands into terminal.  In the project folder, enter command &lt;code&gt;npm init&lt;/code&gt; into terminal to create package.json file.  The package.json file will contain the entry point which is the file that leads to the application.  Express is a node package that is helpful with making routing easier which will help with sending and retrieving information from the server.  To install express, enter command &lt;code&gt;npm install express&lt;/code&gt; and additional node modules will be added to the folder. &lt;/p&gt;

&lt;p&gt;We are now ready to create schemas to store information and routes to send and receive information. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Taking in an Input: In my own words</title>
      <dc:creator>rjdoughty</dc:creator>
      <pubDate>Wed, 07 Nov 2018 05:08:18 +0000</pubDate>
      <link>https://dev.to/rjdoughty/taking-in-an-input-in-my-own-words-4fap</link>
      <guid>https://dev.to/rjdoughty/taking-in-an-input-in-my-own-words-4fap</guid>
      <description>&lt;p&gt;Since my last blog was about inputs, I thought I would follow up with an article on how to take in and console log the value from the form. In order to complete, we will write a function in JavaScript in order to take in the form values. jQuery is a JavaScript library of functions that have been created that will make make the job much easier.   &lt;/p&gt;

&lt;p&gt;Let’s start on the HTML file adding id’s to the inputs created last week. I also created a JS file (app.js) in the same folder as the HTML file. I removed the checkbox for now (I’ll discuss later).  Can’t forget to link our JS file and jQuery to our html file using the script tag and source (src) attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
    &amp;lt;h3&amp;gt;Submit the form&amp;lt;/h3&amp;gt;
    &amp;lt;form&amp;gt;
        &amp;lt;input id="name" type="text" name="name" placeholder="name"/&amp;gt;&amp;lt;br&amp;gt;
        &amp;lt;input id="date" type ="date" name="birthdate"/&amp;gt;&amp;lt;br&amp;gt;
        &amp;lt;input id="email" type="email" name="email" placeholder="name@email.com"/&amp;gt;&amp;lt;br&amp;gt;
        &amp;lt;input id="submit" type ="submit" value="submit"&amp;gt;
    &amp;lt;/form&amp;gt;

    &amp;lt;script src="https://code.jquery.com/jquery.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We will add functions on the app.js file to take in the inputs. jQuery allows us to place a listener on a class or id using “$” as a method &lt;code&gt;$(‘#id’)&lt;/code&gt;.  We can add the jQuery method &lt;code&gt;.on()&lt;/code&gt; which takes in an event (action) and a handler (function) to be completed when the action is made on the id &lt;code&gt;$(‘#id’).on(‘action’, function);&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;For our purposes, I will add the listener to the submit input/button using the id &lt;code&gt;‘submit’&lt;/code&gt;; use &lt;code&gt;‘click’&lt;/code&gt; as the action; and will create a function &lt;code&gt;submitUser&lt;/code&gt; to take in the input values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    $('#submit').on('click', submitUser);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So &lt;code&gt;$('#submit').on('click', submitUser)&lt;/code&gt; calls the function submitUser and take in values when submit is clicked.&lt;/p&gt;

&lt;p&gt;Next, I will create a function (submitUser) to take in the input values.  Inside the function I set a constant (user) equal to an object.  Inside the object, I set a property for each input and assigned keys “name, DOB and email.”&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const submitUser = function() {
    const user = {
        name: $('#name').val(),
        DOB: $('#date').val(),
        email: $('#email').val()
    }
    console.log(user);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;jQuery method &lt;code&gt;.val()&lt;/code&gt; allows us to get values from form elements. &lt;code&gt;$('#id')&lt;/code&gt; we add a listener to the id’s of each of the inputs and add the &lt;code&gt;.val()&lt;/code&gt; method to take in each input &lt;code&gt;$('#id').val()&lt;/code&gt; Inside the function, we add the &lt;code&gt;console.log(user)&lt;/code&gt; to confirm the object has been captured.&lt;/p&gt;

&lt;p&gt;If you open this page in a browser and the console and try using this function, you will notice that when submitting the data, it briefly appears in the console and disappears and the form resets. jQuery has another handy built in method &lt;code&gt;preventdefault()&lt;/code&gt; that we can add to the function and pass in the event to keep the default action from occurring.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const submitUser = function(event) {
    event.preventDefault();

    const user = {
        name: $('#name').val(),
        DOB: $('#date').val(),
        email: $('#email').val()
    }
    console.log(user);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now when we submit the form with the console open, we can see the object appears in the console.  We can now store and manipulate this data as needed. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Dyz4qVAL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/n47d6q8kobyxhlw7vy7p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Dyz4qVAL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/n47d6q8kobyxhlw7vy7p.png" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>HTML Inputs Element: The ears and eyes</title>
      <dc:creator>rjdoughty</dc:creator>
      <pubDate>Wed, 07 Nov 2018 05:07:07 +0000</pubDate>
      <link>https://dev.to/rjdoughty/html-inputs-element--the-ears-and-eyes-l4m</link>
      <guid>https://dev.to/rjdoughty/html-inputs-element--the-ears-and-eyes-l4m</guid>
      <description>&lt;h1&gt;
  
  
  HTML Inputs Element:  The ears and eyes
&lt;/h1&gt;

&lt;p&gt;While working on a project I was thinking about how important the input tag and form element are in the world of development.  Since this is a blog I was trying to find a catchy or charming phrase to describe, the best I could come up with is that input fields are sort of like the ears and eyes that take in details that an end user provides (I guess that would make JavaScript the brain).  &lt;/p&gt;

&lt;p&gt;Inputs simply give us a way to allow applications to take in information from the end user to store (POST) and or manipulate (GET, PUT, DELETE).  Input elements are placed inside a form element to collect inputs. Input elements use different attributes to define and create rules for the input.&lt;/p&gt;

&lt;h2&gt;
  
  
  Attributes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Name
&lt;/h3&gt;

&lt;p&gt;You should always add a &lt;strong&gt;name&lt;/strong&gt; attribute to inputs. The type is defined inside the input tag using &lt;code&gt;&amp;lt;input name=” ”&amp;gt;&lt;/code&gt;. The name attribute is used to reference elements in JavaScript.&lt;/p&gt;

&lt;h3&gt;
  
  
  Type
&lt;/h3&gt;

&lt;p&gt;The input type is useful because they define the input field and create rules based on the type.  The type is defined inside the input tag using &lt;code&gt;&amp;lt;input type=” ”&amp;gt;&lt;/code&gt;. Some common used input types are text, submit and checkbox.&lt;/p&gt;

&lt;p&gt;The most common input type is &lt;strong&gt;text&lt;/strong&gt;, it is the default type if none is assigned and allows a simple text field.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Date&lt;/strong&gt; input type provides a field that requires date format.  The default value inside the field is “mm/dd/yyyy” to require user to enter correct date format.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;email&lt;/strong&gt; input type provides a field that requires text in email format.&lt;/p&gt;

&lt;p&gt;The input type &lt;strong&gt;checkbox&lt;/strong&gt; is shown as a square box that is ticked (checked) when activated.  An additional attribute of “checked” or “unchecked” can be assigned to a checkbox to force the box to be checked when the page loads.  The default is unchecked.&lt;/p&gt;

&lt;p&gt;The submit input type creates a submit button that is used to submit or send the form info.  The default text inside the submit button is “submit”.&lt;/p&gt;

&lt;p&gt;See the following code below of an input form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form&amp;gt;
    &amp;lt;input type="text" name="name" placeholder="name"/&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type ="date" name="birthdate"/&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="email" name="email" placeholder="name@email.com"/&amp;gt;&amp;lt;br&amp;gt;
    Sign me up for email updates&amp;lt;input type="checkbox" name="subscribe"  value="Subscriber" checked/&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type ="submit" value="Submit"&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Other
&lt;/h3&gt;

&lt;p&gt;Inputs can be further enhanced using other attributes. Attributes can set rules for inputs and assist with user experience.  Common attributes &lt;strong&gt;value&lt;/strong&gt; and &lt;strong&gt;placeholder&lt;/strong&gt; add default text to the input field.  Placeholder provides the user a hint of the requested input while value stipulates an input value provided.&lt;/p&gt;

&lt;p&gt;Below is shows the form on the page:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc50kkqypxccioossizjc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc50kkqypxccioossizjc.png" alt="alt text" width="234" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stay tuned for future discussions on how to take in using GET, POST, PUT and DELETE methods....&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
