Admittedly I am only a beginner at playing with java but I'm pulling my hair out trying to understand something I thought would be easy, and it probably is. Trying to write code that randomly selects from 3 preloaded arrays and spits out the results. Mechanically the code seems to work fine but I'd like the result in a different format than this code gives. Currently the 3 individual selections are displayed in input boxes.
<html>
<head>
<title>Home</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
var girl = new Array("Michelle","Sandy","Mary")
var place = new Array("dinner","movies","beach")
var day = new Array("Friday","Saturday","Sunday")
var suggestion
var i=0
function PickDate()
{
{
i=Math.floor(Math.random() * girl.length);
document.DatePick.GIRL.value=girl[i]
}
{
i=Math.floor(Math.random() * place.length);
document.DatePick.PLACE.value=place[i]
}
{
i=Math.floor(Math.random() * day.length);
document.DatePick.DAY.value=day[i]
}
}
</SCRIPT>
<CENTER>
<h2>Date Picker</h2>
<FORM NAME="DatePick">
<INPUT NAME="GIRL">
<INPUT NAME="PLACE">
<INPUT NAME="DAY">
<br>
<INPUT TYPE="BUTTON" NAME="Button1" VALUE="Generate Your Date!" ONCLICK="PickDate()">
<br>
document.write ("Take "GIRL" to the "PLACE" on "DAY);
</FORM>
</body>
</html>
I want to do away with the 3 input boxes and have the result printed out as a single line with the individual selections embedded in a sentance similar to the doc.write command above
ie: Take Michelle to the movies on Friday.
Thanks!