I’m making a random generator that takes a bunch of customizable info, runs some random numbers, and then tosses out some random scenarios based on those. “What percent of the population is affected?” “What are they affected by?” Those things. I’ve learned how to make textboxes (I haven’t learned how to make info not temporary and I just live in constant errors, now, because it shows an error every time there’s an “undefined” box) and I’ve learned how to make multiple dropdown lists. However, when I try to attach outputs to them, it doesn’t work. Attaching a button to it will randomize the output. I want to add a description, so when someone chooses “Option One” they get a short dialogue beside it to give them a feel of what it may be like. Currently, if I have “Option One” chosen and I press the button, the dialogue for Option Eight could appear or Option Three or Option Five just as easily as Option One.
Here’s what the code itself looks like (BTW this is my first generator. I’ve used very basic HTML like embedding links and formatting for years and I’m getting into game design and learning how to use minor C++/Unreal Engine, but I’ve never used JS before)
Thank you very much for taking the time to help me! I tried this, and it still didn’t work, changing the “false” after the dialogue to “(syntax error)”/ Which, I’m not sure why there’s a false there to begin with. I did the changes you suggested as well as replaced spaces with underscores. The error I’m getting is the same one, but on lines 28 (The Clan will feel this for a long time. [aListName.Death_Chance == “Devastation”] //41-50%) and 35 (Cold weather chest infection, could turn to greencough. [aListName.Illness_type == “Whitecough”]).
An error has occurred near line number 28: There’s a problem with the syntax of this expression: ‘[aListName.Death_Chance == “Devastation”]’. Here’s the message that was returned when execution failed: Cannot read properties of undefined (reading ‘Death_Chance’). Here are some common mistakes: *you tried to reference a variable/list that you haven’t created *list names are case-sensitive: “[animal]” is different to [Animal], and you should use underscores in list names instead of spaces
An error has occurred near line number 35: There’s a problem with the syntax of this expression: ‘[aListName.Illness_type == “Whitecough”]’. Here’s the message that was returned when execution failed: Cannot read properties of undefined (reading ‘Illness_type’). Here are some common mistakes: *you tried to reference a variable/list that you haven’t created *list names are case-sensitive: “[animal]” is different to [Animal], and you should use underscores in list names instead of spaces
Did you put the
Death_Chance
andIllness_type
variables into a parent list like this?someListName Death_Chance = Moral Blow Illness type = Whitecough
If so, you’d need to change the
aListName
part of the syntax to reference the name of the sublist:<br>Death Chance: <select oninput="someListName.Death_Chance = this.value"> <option value="Moral Blow">Moral Blow</option> ... <br>Illness type: <select oninput="someListName.Illness_type = this.value"> <option value="Whitecough">Whitecough</option>
[someListName.Death_Chance == "Moral Blow"]