Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Jonathan Herman
    @lantech19446
    so far this is really good
    Lily Romano
    @Lilyheart
    That's awesome! I'll add it to the list to add! fantastic :octocat:
    Jonathan Herman
    @lantech19446
    I'm trying to delve deeper into it now while I'm doing these classes but I can't see why this keeps telling me that firstName is undefined, do you see what I'm doing wrong?
    http://codepen.io/lantech19446/pen/YWNVVK
    Lily Romano
    @Lilyheart
    When something with a = is evaluated, the right side is calculated then assigned to the left. sum = 2 + 2;
    Try switching your document.getElementById("first").value = firstName; around
    I'm not sure why you have the push in there.
    Jonathan Herman
    @lantech19446
    I tried switching them before and still got that error that was why I flipped them the push was in there because it's the only way I could figure out to get it to pass the value into the array
    Lily Romano
    @Lilyheart
    firstName is actually a string at the moment, let me fork it and show you how you can test it.
    Jonathan Herman
    @lantech19446
    ok thanks
    Jonathan Herman
    @lantech19446
    switched that back around and defined firstName as an empty array still get reference error firstName undefined. Seeing the right way to do this should remove a big road block
    Lily Romano
    @Lilyheart
    almost done. just asec
    Jonathan Herman
    @lantech19446
    k
    Lily Romano
    @Lilyheart
    Maybe @davidjcastner can add onto this http://codepen.io/lilyheart/pen/GqrEmM/
    If you are wanting something that will keep adding to the array, here is a fork of the fork. (see my comments at the bottom of the js to explain a little more. http://codepen.io/lilyheart/pen/gMgRXv
    Jonathan Herman
    @lantech19446
    nice
    Jonathan Herman
    @lantech19446
    so am I understanding this correctly that part of the problem is that I need to have a scope that the array is contained within?
    Lily Romano
    @Lilyheart
    Scope is a problem is two ways.
    A variable declared in the function is only in scope when the function is running and the variable disappears as soon as the function is done.
    A variable declared outside the function is only in scope for as long as the page is loaded. A button (submit or <button>) refreshes your page thus resetting your scope.
    Jonathan Herman
    @lantech19446
    ok that makes sense not necessarily why it was designed that way but that it'll happen but I need to have a scope and the array must be a method within that scope it can't exist on it's own.
    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