I want to include a Json file which holds data so I can pull it into my HTML file to use in creating a dynamic select option form.
For example if the first select option asks if you’re a man or a woman, and lists man and woman as the choices, the next select option that is dynamically created would have choices specific to what you previously choice and those choices would be pulled from the Json file.
I want to be able to get that data if I say like
Var data= new object();
Data['male']=['tall', 'short'];
data['tall']=['rich', 'poor'];
I think this structure is similar to associative arrays but I’m not too sure. So with the above lines, if the person chose male they would be given the options of tall or short, and if thy chose all they would be given the options of rich or poor.
I think the Json would be something like
{"data": {
man:[];
woman:[];
}
}
If you could point me in the right direction of how to do this with an example, I would very much appreciate it, I don’t have much experience writing Json myself.
You’re on the right track, barring a couple of issues:
Keep in mind that JSON should always use double quotes (
"") for both keys and content.