简体   繁体   中英

Creating a pop-up alert

Im doing an assignment where I have to create a form where the user can enter multiple values... values in a text box as well as choosing 1 option from a radio button. I need to create an alert that shows the user their choices.. I have found a way to create an alert but it only allows me to 1 value... see below

    var username=document.getElementById("yourname").value;
    var toAlert="Thank you "+username;
    toAlert=toAlert+", have a good day";
    alert(toAlert);

but like I said, it need the alert to indicate multiple values. Simply adding additional "+blahblah" does not work... I hope this question makes sense...

I also need to know how I can get the user's radio button selection in the pop up as well...

create field called eg secondfield

 var username=document.getElementById("yourname").value;
 var secondfield=document.getElementById("secondfield").value;
 var toAlert="Thank you "+username+", have a good day. Second field: "+secondfield;
 alert(toAlert);

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