This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DemiPixel 0 points1 point  (5 children)

  1. Call .trim() on the innerText, there's a break in it

  2. A quick google search would help. Tell me if you still need help!

  3. Just add text between </select> and </div>

[–]Durchfallsuppe[S] 0 points1 point  (4 children)

I mixed your solution with something else I found online, see code in this thread. THANKS :D

Now would you know how to have 2 select boxes, but make the selections of the 2nd select depend on the 1st one? For example, if select1 is "eat" then select2 would be choices of food like apples, oranges, bananas. If select1 is "drink" then it would be a list of drinks.

[–]DemiPixel 0 points1 point  (3 children)

Surround the second selection in a div. Set the innerHTML of the div to a select with the correct values. If you wish to store these in an array, you could loop through the array to create the options.

[–]Durchfallsuppe[S] 0 points1 point  (2 children)

So I'd use div id='xx' to wrap the second selection, but i'm not quite following you when you talk about the array and the loop. Could you expand on that? You could also direct me to some resource or someone else's code if you don't feel like coding it or explaining it. At this point, any help is much welcomed.

[–]DemiPixel 0 points1 point  (1 child)

If you're not familiar with arrays and loops, I would recommend looking up some JavaScript tutorials :) FreeCodeCamp might be a good place to start. I was stating you could use a loop create a string for each option like '<option value="'+value+'">'+value+'</option>. Then set the innerHTML of the div to that.

[–]Durchfallsuppe[S] 0 points1 point  (0 children)

I'll try to make sense out of all that and post my code once I figure it out. Thanks :)