www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

     
     
    Thread Tools Rate Thread Display Modes
    Prev Previous Post   Next Post Next
      #1  
    Old 11-29-2003, 07:06 AM
    Melons Melons is offline
    Registered User
     
    Join Date: Mar 2003
    Posts: 15
    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)
    Reply With Quote
     

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:26 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.