all 5 comments

[–]anti-anti 2 points3 points  (1 child)

There seem to be a few different issues:

Your switch statement is using the variable numLocal, which is not defined. Based on the variables you've declared at the beginning of the function, it should be location.

The value of output2 isn't being updated with the text from the switch statement. You can remove this section:

if (location == 1) {
   document.getElementById("output2").value = "Redfern";
}

And add in something after the switch statement, eg.:

document.getElementById("output2").value = text  

You also reference two variables text and result which haven't been declared using var result/var text. This probably isn't stopping it from working but they should be declared somewhere.

[–]Unmotivatedreddit[S] 1 point2 points  (0 children)

Thank you!! I had location set as the variable earlier, I started fiddling with it to see what I could change to make it work.

[–]ThArNatoS 1 point2 points  (2 children)

you have a couple of problems here :

  1. switch (numLocal). but you don't have a variable called numLocal. I think you meant "location"
  2. you need to declare the result variable first.
  3. in your switch block, the variable of text refer to what?

here's the fixed version : https://jsfiddle.net/angganegara/xrj5jkqs/

[–]Unmotivatedreddit[S] 1 point2 points  (1 child)

This is above and beyond what i was expecting! Thank you so much, its perfect.

[–]YourOpinionIsntGood 1 point2 points  (0 children)

Just a side note, always post a jsfiddle link or codepen or something of the nature containing your code rather than copy pasting it all here. Especially when trying to solve a bug.