• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help creating random phrase generator with jscript

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I haven't really used javascript before except for the odd snippet, and I was wondering if anyone can help me with a problem I have:

I need a script that chooses a phrase at random from 4 pre-defined lists of phrases, and does it all from the one page - rather than a separate page and a separate script for each pre-defined list of phrases.

I hope this is clear enough! Here is an example to illustrate what I mean:

This would be the text that appears on the webpage:
  • Click here for random Phrase Type 1
  • Click here for random Phrase Type 2
  • Click here for random Phrase Type 3
  • Click here for random Phrase Type 4


  • When clicking the first option, it only chooses from pre-defined list #1, the second option only chooses from pre-defined list #2, and so on.

    It then displays the randomly generated phrase in one separate box, no matter what pre-defined list was chosen. (Although if each phrase has to be displayed in 4 separate boxes, that'd be ok too.)

    I hope someone can help!
     
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    "snapd", please check your private messages for an important message from me.
     
    (instanceof Sidekick)
    Posts: 8791
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi, welcome to the ranch!

    Sounds like you have several problems to solve and it's hard to tell which one has you stuck right now. Are you ok with ...

    ... put a button and a place to show each phrase on a page?

    ... make some script run when the user clicks the button?

    ... pick a random phrase from a list?

    ... put the phrase into the display?

    If you're comfortable with any of this, put some code together to show us what you have. The Ranch works great when you show something that almost works!
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic