Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Check that out at least up to where he talks about hoisting. Don't need to worry about that yet but feel free to read it if you wanna xD
    Jonathan Herman
    @lantech19446
    ok
    thanks Lily
    Lily Romano
    @Lilyheart
    As to why it was designed that way: The purpose of a button is to take that information from the page and send it somewhere via an HTTP request. It just happens to be that your page sends you back to itself and the function is grabbing the result.
    Jonathan Herman
    @lantech19446
    interesting
    Lily Romano
    @Lilyheart
    Less then 5 hours of the Colt Steele bootcamp left. Whoa.
    Jonathan Herman
    @lantech19446
    awesome!, I think I'm sticking with the watchandcode. I might not have been able to accomplish that on my own but it's the closest I've gotten through any of them
    Lily Romano
    @Lilyheart
    Awesome!!! We can always fill in the blanks for you here!
    Jonathan Herman
    @lantech19446
    yea you guys are great at that
    Lily Romano
    @Lilyheart
    I have yet to find the "perfect" training. At least not for free. I combined many many resources to try to get a complete picture.
    David Castner
    @davidjcastner
    Had a busy day at work, only seeing stuff now. @lantech19446 I've never heard of plunker before, so nothing of value that I can say.
    David Castner
    @davidjcastner
    I see that you are starting to work with forms, how fun... and I see you are having some trouble with form submit, don't worry though, you can always overwrite the default behavior or a form. I'll put together an example
    Jonathan Herman
    @lantech19446
    the forms were honestly just the easiest way I could think of to input random data into an array, I learned the array stuff a little better on watchandcode googled to fill in some blanks and then ran into some other issues that I posted here
    Lily Romano
    @Lilyheart
    That second pen shows how you can make anything "onclick"
    David Castner
    @davidjcastner
    @lantech19446 is there a specific task you were trying to accomplish?
    Jonathan Herman
    @lantech19446
    I just wanted to take whatever I submitted into the form and have it add it to the array and then spit it back
    David Castner
    @davidjcastner
    Here is how to overwrite the form behavior and add to a list http://codepen.io/davidjcastner/pen/RRKZWB
    You can overwrite any event or event listener in js
    Jonathan Herman
    @lantech19446
    awesome, and I actually understand what you did there which makes me incredibly happy
    David Castner
    @davidjcastner
    one sec changing it real quick to demonstrate an alternative way
    Jonathan Herman
    @lantech19446
    ok
    David Castner
    @davidjcastner
    btw you can also you us the jquery library but knowing the pure javascript way is better and more informational
    Jonathan Herman
    @lantech19446
    yea, I'm doing the watchandcode lessons Lily posted last night and when I finish that I'm going to do an outside course on jquery, I understood it when I went through it but nowhere near as well as I'd like too.
    David Castner
    @davidjcastner
    @lantech19446 nevermin, what I was trying didn't work, but that's the way to do it in pure js
    Jonathan Herman
    @lantech19446
    that's pretty cool, I notice that you have a way to clear the list and it looked like i just needed to submit an empty field but that didn't quite work. What was I missing there
    David Castner
    @davidjcastner
    @lantech19446 technically forms by default don't actually clear inputs, instead there default behavior is to reload the page which in turn clears the inputs. We have to clear the inputs manually since we overwrote the default behavior. You could simplify this process by looping over all of the form inputs and setting their value to an empty string. Also overwriting form behavior is extremely common
    hope that helps, let me know if you have more questions about forms
    about 75% of my work day is dealing with the little devils
    Jonathan Herman
    @lantech19446
    so what you're accomplishing by input.value = ''; is overwriting the value assigned to input not actually providing a way to clear the items that have been fed to the list
    David Castner
    @davidjcastner
    yea there is a value attribute for input elements http://www.w3schools.com/tags/att_input_value.asp
    Jonathan Herman
    @lantech19446
    ok
    David Castner
    @davidjcastner

    you can use this to set the value of the input when the page first loads too

    <input type="text" value="hello world">

    this input will start with hello world

    Note: this is different from the placeholder attribute which is like a fake version of value. The value of the input is still an empty string, and as soon as you start typing the placeholder value will disapppear.

    Example:

    <input type="text" placeholder="enter your name">
    Jonathan Herman
    @lantech19446
    right
    David Castner
    @davidjcastner

    Just looked this up, but a"more correct" way to clear inputs is to use

    inputElement.value = null;

    this has the added benefit (if this is want you want to happen of course) of removing the focus on the input. I've always used an empty string though and never had a problem

    Jonathan Herman
    @lantech19446
    dave, do you have your own copy of the ecma standard?
    David Castner
    @davidjcastner
    No I do not, but I usually read the articles that comes out about the changes to ecmascript
    Jonathan Herman
    @lantech19446
    o ok when you said you looked it up I was like well hell does he actually have like a printed out copy of ecma5 he uses as a desk reference lol
    David Castner
    @davidjcastner

    and here is the "correct way" to clear an entire form:

    <form id="form">
        <input id="input">
    </form>
    //document.getElementById('input').value = null; // sinlge input
    document.getElementById('form').reset(); //all inputs

    again this has the added action of removing the focus from the form (prevents double submissions)

    Jonathan Herman
    @lantech19446
    interesting
    Mike
    @dcpking
    Printed copy, Jonathan? Nope. It's all in a small USB plug located just behind his left ear :)
    Jonathan Herman
    @lantech19446
    lol
    David Castner
    @davidjcastner
    hah
    Jonathan Herman
    @lantech19446
    if only that were true and I could just download the knowledge about javascript lol David would be the giver
    David Castner
    @davidjcastner
    I am always learning new things, I think I will implement this at work starting monday
    Jonathan Herman
    @lantech19446
    btw @dcpking have you ever been so happy to be on this side of the pond as you are today?
    David Castner
    @davidjcastner
    you mean Britain leaving the EU?
    Mike
    @dcpking
    Total shock! First thought was "where are all the birth certs and all ... time to head down to D.C. and the Irish Embassy to get my citizenship !