vendredi 3 décembre 2021

put information from a javascript array in an html checkbox

I'm trying to create a test to see what football shoe somebody needs. I have a javascript array and i want to put it in a loop so it creates an html checkbox for each question in the array.

My array:

    var FootballShoeTest = [
        [
            'Whats your size?',
            ['41', 'url1'],
            ['42', 'url2'],
            ['43', 'url3']
        ],
        [
            'What color would you like?',
            ['Red', 'url1'],
            ['Blue', 'url2'],
            ['Yellow', 'url3'],
            ['Green', 'url4']
        ],
        [
            'What brand would you like?',
            ['Adidas', 'url1'],
            ['Nike', 'url2'],
            ['Puma', 'url3']
        ]
    ];

    var SizeUrl = '';
    var ColorUrl = '';
    var BrandUrl = '';

I need to create multiple input quiz like questions looking like this:

What's your size?
[ ] 41
[ ] 42
[ ] 43

What color would you like?
[ ] Red
[ ] Blue
[ ] Yellow
[ ] Green

What brand would you like?
[ ] Adidas
[ ] Nike 
[ ] Puma

And when I click on an awnser for my size i want the variable SizeUrl to change to the url that belongs to the awnser (so when I click on 42 it would change to url2) and the same counts for the other questions. Does anybody know a way to do this?




Aucun commentaire:

Enregistrer un commentaire