Home > Net >  How to have a "Response" page?
How to have a "Response" page?

Time:11-19

sorry but I am French and my English is bad, I use "Google Trad" to help me, I am sorry if it is weird reading me. I create a "Blind Test" type game, I ask for 3 titles from a singer, so I create an object in Javascript with the singer then the titles.

function Chanson(chanteur, titre1, titre2, titre3, titre4, titre5, titre6, titre7, titre8, titre9, titre10) {
    this.chanteur = chanteur;
    this.titre1 = titre1;
    this.titre2 = titre2;
    this.titre3 = titre3;
    this.titre4 = titre4;
    this.titre5 = titre5;
    this.titre6 = titre6;
    this.titre7 = titre7;
    this.titre8 = titre8;
    this.titre9 = titre9;
    this.titre10 = titre10;
}

Then I create some singers and songs.

let Sardou = new Chanson("Michel Sardou", "Les lacs du Connemara", "Je vais t'aimer", "La maladie d'amour", "En chantant", "Être une femme", "La java de Broadway", "Le rire du Sergent", "La France", "Je vole", "Afrique adieu")
let Goldman = new Chanson("Jean-Jacques Goldman", "Il suffira d'un signe", "Comme toi", "Envole-moi", "Au bout de mes rêves", "Je marche seul", "Il changeait la vie", "La vie par procuration", "A nos actes manqués", "Encore un matin", "Né en 17 a Leydenstadt")
let Dassin = new Chanson("Joe Dassin", "Les Champs-Elysées", "Et si tu n'existais pas", "L'été Indien", "Dans les yeux d'Émilie", "A toi", "Siffler sur la colline", "Le petit pain au chocolat", "Ca va pas changer le monde", "Salut les amoureux", "La fleur aux dents", "<img src='img/joedassin.jpg'>")
let Hallyday = new Chanson("Johnny Hallyday", "L'envie", "Allumer le feu", "Quelque chose de Tenessee", "Le pénitencier", "Diego libre dans sa tête", "Requiem pour un fou", "Je te promet", "Que je t'aime", "Gabrielle", "Vivre pour le meilleur")
let Indochine = new Chanson("Indochine", "J'ai demandé à la lune", "L'aventurier", "Trois nuits par semaine", "3e Sexe", "Tes yeux Noir", "Un été Français", "Nos célébrations", "Juste toi et moi", "Miss Paramount", "Les Tzars")
let Aznavour = new Chanson("Charles Aznavour", "La Bohème", "Emmenez-moi", "Hier encore", "J'me voyais déjà", "Mes emmerdes", "For me Formidable", "Les Comédiens", "Non je n'ai rien oublié", "La mamma", "Mourir d'aimer")

I then make a table.

const MesChansons = [Sardou, Goldman, Dassin, Hallyday, Indochine, Aznavour]

Then I use a "Math Random" to have a singer randomly. And I place them in my DOM.

const ChansonHasard = MesChansons[Math.floor(Math.random() * MesChansons.length)];

document.getElementById("achanger").innerHTML = ChansonHasard.chanteur
document.querySelector("p.t1").innerHTML = ChansonHasard.titre1
document.querySelector("p.t2").innerHTML = ChansonHasard.titre2
document.querySelector("p.t3").innerHTML = ChansonHasard.titre3
document.querySelector("p.t4").innerHTML = ChansonHasard.titre4
document.querySelector("p.t5").innerHTML = ChansonHasard.titre5
document.querySelector("p.t6").innerHTML = ChansonHasard.titre6
document.querySelector("p.t7").innerHTML = ChansonHasard.titre7
document.querySelector("p.t8").innerHTML = ChansonHasard.titre8
document.querySelector("p.t9").innerHTML = ChansonHasard.titre9
document.querySelector("p.t10").innerHTML = ChansonHasard.titre10

Then I hide them with an image, and I create a "Flip ()" to flip and see the title (a bit like "Family Feud") I can't memorize all the locations when I play so I would like to have another "Response" page. The same page without the images that hides the answers. The problem is that I use "Math Random" so from page to page I wouldn't have the same singer. So ... do you have any ideas? Thanks again for reading me.

CodePudding user response:

Below is my suggestion

Its cleaner/safer to have the values saved in a database as against another web page.

So create a database and have the values inputed into it everytime a title is chosen, i hope this helps.

CodePudding user response:

Use url parameters to pass a seed. The host page can provide a link including the seed. The link can be to the same page, but with url parameters. Host/guest uses the seed provided or generates one otherwise. This is consistent.

  • Related