|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
math random word arrays
Hi,
can anyone help me please? What I want to do is to be able to select a random array of words/phrases from several individual arrays and then depending on the word /phrase selected to be able to force to another array for the next line. In my html file I have the following : _______________________ var txt = "<p align='center'><font face='Arial' size=5 color=#400040>" var hold1=1 var hold2=1 for (i = 0; i <= 0; i++) // changes number of verses {hold1=Math.round(Math.random() ) hold2=Math.round(Math.random() ) txt = a1[Math.round(Math.random() * 164)] + " " + b1[Math.round(Math.random() * 107)] + " " + c1[Math.round(Math.random() * 83)] + " " _____________________ and in my js file I have the following : var a1 = new Array(164) var b1 = new Array(107) var c1 = new Array(83) and then all the words for a1, b1 and c1 listed. ______________________ This works fine for the moment as a basic phrase, word, poem generator. What I want to do is to have a random word taken from a1, b1 and c1 arrays combined and then depending on the word chosen to be able to select the next word from a different array. For instance, the first line of text I would want to be randomly chosen from a1 and b1 and c1. The second line of text would depend on which word was chosen and from which array it came from, so, if the first line was randomly chosen from a1, b1 and c1 and the actual word/phrase chosen came from b1 then I would want the next line to choose from an array b2. If, however, i the first line was randomly chosen from a1, b1 and c1 and the actual word/phrase chosen came from a1 then I would want the next line to choose from an array a2 etc. In this way I can place similar words and phrases within an array and then, depending on what one is chosen force the system to randomly select a related word or phrase from another array. Does anyone know how I can do this please?? Did I explain it ok or have I just confused everyone? Best regards, Mel ...fingers crossed someone can help me as I am a bit naff at this kind of thing...........(examples of code written for me might be nice lol *winking) |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|