SnowyWolf,
<!DOCTYPE HTML>
<html>
<head>
<title>16.05.2014</title>
<meta charset="utf-8">
</head>
<body>
<script language=javascript type=text/javascript>
function gold(col)
{
col = parseInt(col)||1;
var i;
var min = 20, max = 30;
var tw = 0;
var w = new Array();
for (i = 0; i<col; i++)
{
w[i] = Math.floor(min+(Math.random()*(max-min)));
tw = tw+w[i];
};
var html = "<table border=3 cellspacing=5 cellpadding=5 rules=all>";
html += "<tr>"
for (i = 0; i<col; i++){html += "<td>"+w[i]+"</td>"}
html += "</tr>"
html += "</table>";
document.getElementById("show").innerHTML = html
document.getElementById('weight').value = tw;
return;
}
</script>
<form>
Количество монет:<input type="text" value="" name="col">
<input type="button" onclick="gold(col.value)" value="Разделим золото"><br>
Общий вес золота:<textarea id="weight" rows="1" cols="15"></textarea><br>
Большая часть:<textarea name="more" rows="1" cols="15"></textarea><br>
Меньшая часть:<textarea name="less" rows="1" cols="15"></textarea><br>
Разница в весе:<textarea name="difference" rows="1" cols="15"></textarea>
</form>
<div id="show"></div>
</body>
</html>