简体   繁体   中英

How can one generate a dynamic page based on variable values in Javascript?

I currently have a webpage that is a very basic quiz in Javascript. Each radio button is weighted toward a specific set of variables such that the variable with the highest "score" will be the result. How can one create a new webpage with the result once you have this value?

Let's take, for example, what kind of car you would like:

porsche = 0
ford = 0
toyota = 0

And because you are a speed demon and answer accordingly, your end result is:

porsche = 52
ford = 16
toyota = 33

How can I generate HTML (or similar) which has a page with a picture of a Porsche?

if (porsche > ford && porsche > toyota)
{
    // generate Porsche page
}
else if (ford > porsche && ford > toyota)
{
    // generate Ford page
}
else if (toyota > porsche && toyota > ford)
{
    // generate Toyota page
}
else
{
    // a page for everything else
}

I of course can do the actual HTML/CSS/etc. on my own but there is no obvious way to do dynamic results pages (at least from my searches).

maybe window.open() function helps you

var myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px 
tall!</p>");

https://www.w3schools.com/jsref/met_win_open.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM