简体   繁体   English

创建弹出警报

[英]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. 我正在做一个作业,我必须创建一个表单,用户可以在其中输入多个值...在文本框中输入值,以及从单选按钮中选择1个选项。 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 我需要创建一个警报来向用户显示他们的选择。.我找到了一种创建警报的方法,但它只允许我输入1值...请参见下文

    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... 仅仅添加其他的“ + blahblah”是行不通的...我希望这个问题是有意义的...

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 创建一个名为例如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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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