Git Product home page Git Product logo

cssi-3-jquery-html-forms-walkthrough's Introduction

tags level languages resources

Html Forms And Jquery

Lots of the interaction on the web happens through forms. (For the most part) Whenever you are typing something into a box, clicking a checkbox or radio button, or sliding a slider, you are interacting with an HTML Form.

Facebook status update? Form. Tweet? Form. Instagram picture upload? Form!

So, how do we get form data with jQuery?

As users are entering text in HTML text fields or changing values of checkboxes, sliders, and radio buttons, the browser is smart enough to already be updating the DOM with that information. Because the data is in the DOM, we can get it with javascript, and use it!

If we have an html input on our webpage:

Enter your text here:
<input type="text">

Then we can get it with jQuery:

var user_text = $('input').val();

And once we have it, we can use what we know to show it back to them:

$('#results').text(user_text);

Of course, we can manipulate the text before displaying it to the user.

var user_text = $('input').val();
$('#results').text(pigLatin(user_text));

HTML Forms have all kinds of input that we can play with.

<form>
  Name:
 <input type="text" value="name">
 How was your experience today?
 <select name="rating">
  <option value="strange">Strange</option>
  <option value="unnerving">Unnerving</option>
  <option value="spooky">Spooky</option>
  <option value="shocking">Shocking</option>
  <option value="blase">Blase</option>
</select>
 What was your favorite?
<input list="favorites">
<datalist id="favorites">
  <option value="ghost">
  <option value="clown">
  <option value="werewolf">
  <option value="vampire">
  <option value="wereclown">
</datalist>
 Feedback:
 <textarea name="feedback" rows="10" cols="40">
 <button onclick="showResults()">Show Results</button>
</form>

We see:

  • text inputs
  • select from options
  • dropdown list
  • textarea
  • buttons

There are even more elements to find and use - try searching for them!

View Html Forms And Jquery on Learn.co and start learning to code for free.

cssi-3-jquery-html-forms-walkthrough's People

Contributors

rrcobb avatar sarogers avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.