<!DOCTYPE html>
<html><head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251' />
<script src='http://code.jquery.com/jquery-latest.js'></script>
<script src="https://code.angularjs.org/1.3.9/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.9/angular-route.js"></script>
<style type='text/css'>
body {margin: auto;}textarea {height: 100px;width: 30%;margin: auto;border: none;background: #eee;outline: none;}
#rescount {width: 8%;height: 100px;background: #eee;display: inline-block;position: fixed;padding: 5px;text-align: center;font-size: 3em;}
#rescount span {font-size: 12px;}
.generate {width: 100%;height: 30px;border: none;background: #eee;outline: none;}
table, td {width: 100%;}
td {background:#c2ff9b;}
</style><script type='text/javascript'>
function newgen(){
var cols=0;
var or=document.getElementById('result');
var rc=document.getElementById('rescount');
var gruz = document.getElementById('gruz').innerHTML;
gruz = gruz.split(/\n/);
var gorod = document.getElementById('gorod').innerHTML;
gorod = gorod.split(/\n/);
var avto = document.getElementById('avto').innerHTML;
avto = avto.split(/\n/);
function rand(item) {
return item[Math.round(Math.random() * (item.length - 1))];
}
or.innerHTML='';
rc.innerHTML='';
var data = [];
gruz.forEach(function(rndgrz) {
gorod.forEach(function(first) {
avto.forEach(function(second) {
var g = rndgrz.split(',');
g = rand(g);
data.push(g + ' ' + first + ' ' + second);
cols=cols+1;
});
});
});
// это для примера
data.forEach(function(item) {
or.innerHTML += '<td>' + item + '</td>';
});
rc.innerHTML=cols;
}
</script></head><body>
<textarea id="gruz">
Саня,Леха,Толик
Вова,Женя,Игорь</textarea>
<textarea id="gorod">
Любит
Не любит</textarea>
<textarea id="avto">
Олю
Надю
Иру
Машу
Дашу</textarea>
<div id="rescount"></div><br/><input type="button" onclick='newgen();' class="generate" value="СГЕНЕРИРОВАТЬ"/>
<table><tbody id="result"></tbody></table></body></html>