Use Array based on User Input

Ok. So they can keep adding entries for as long as they want, right?

If so, why the need for arrays - this is what I am missing.

Do the results need to be sorted, maybe?

There’s actually no need for sorting. However I was thinking (as part of learning JS) to find a way of deleting (taking out) containers later on. I thought arrays would be the a good way to do this.
But this would be my next try.

Like I said still learning

So what about if you have your three input fields to generate the codes.
As the codes are generated, they stack up one after another within the results div.
We could add a delete link after each code (which is maybe invisible until you hover over the respective code).
Once the link is clicked, the element is removed from the page.

Does that sound reasonable?

Sounds awesome!

Ok, well I gotta shoot off for a while. I’ll make a simple demo later on.

Simple demo using jQuery: http://jsfiddle.net/7tvgyceb/

Cool, but the OP said:

Might be a good learning exercise to translate it, though.

Ah, missed that, sorry
But anyway, I think it is a lot easier to learn jQuery before vanilla Javascript as it allows to write much less code and simplifies many things

Hmm, not sure where I stand on that one. Don’t get me wrong, I love jQuery and I use it for almost everything, but I would have thought it helps to understand what’s going on under the hood to some extent.

My position is simple - while you’re beginner it’s better for you to write as little code as possible.
Because that allows you to focus more on the logic of your program, instead of trying to remember which operator to use. I think that is the reason why Basic and other languages made for learning have so simple syntax. This is just a private opinion, of course.

Now I’m just waiting for felgall : )

I agree with that. Working up code in bite sized amounts does make learning easier as it is more likely to encounter only one problem at a time.

But I’m not so sure learning jQuery first is advisable. IMHO definitely not until after there is a good grasp of JavaScript basics.

There are enough differences between jQuery JavaScript and non-jQuery JavaScript that jQuery has a learning curve and I think for some trying to learn both at the same time might get in the way.

Don’t get me wrong, I like using jQuery at times.

I have seen a fair number of posts here where a member has copy-paste some jQuery code and is having problems with it because they don’t understand JavaScript all that well.

I think the jQuery documentation is good, but from what I’ve seen it doesn’t go into much detail about the root JavaScript something may be using.

i.e. jQuery is a tool that can be used by JavaScript developers and at least some understanding of non-jQuery JavaScript is a prerequisite.

You (and Pullo) are absolutely right, it is required to know some Javascript basics in order to use jQuery or any other framework. When I told “vanilla Javascript” I meant only DOM-manipulation side of it. In other words, I think there is no need to remember that ugly document.getElementById when you can use $() immediately. But this doesn’t mean you are free from learning about all other aspects of the language, like operators, events model, objects and so on.

In my example with document.getElementById('id') and $('#id') both return object representation of DOM element. And this is the general idea which beginner should get. What exactly to type to achieve that result - isn’t important, it’s just a question of syntax.

Thank you for your solution megazoid.
I will use this example to get more familiar with jquery.
For the moment though I am looking for a JS solution.

By the way, I can’t see how to use the x-button in the format I am aiming for.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.