我需要创建一个随机引用生成器,它根据用户在表单上输入的内容显示1到10之间的多个引号。我在HTML文件中调用onsubmit =“generate()”函数。到目前为止,我在js文件中有以下内容:
var quotes = [
"This is a sample quote. - me",
"This is a sample quote. - me",
"This is a sample quote. - me",
"This is a sample quote. - me",
"This is a sample quote. - me",
"This is a sample quote. - me",
"This is a sample quote. - me",
"This is a sample quote. - me",
"This is a sample quote. - me",
"This is a sample quote. - me"
];
function generate() {
var number = document.getElementById('numInput').value;
var random = Math.floor(Math.random() * quotes.length);
document.getElementById('goodQuotes').innerHTML = number[random];
}
如果用户输入1到10之间的任何数字,我需要在页面上显示多个引号。任何帮助都会有所帮助。感谢。