Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3752748
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:17:22+00:00 2026-05-19T09:17:22+00:00

I am creating a web page where someone can visit it. They type a

  • 0

I am creating a web page where someone can visit it. They type a question in a field and click a button, and a response is passed back to them. (Kind of like a magic 8 ball).

What I’m trying to do is set it up something like this:

http://img585.imageshack.us/img585/997/layoutoi.png

I’m still new to hand-coding things – I have a book on HTML/CSS and one on PHP, which lay still unread, so I’ll probably need a step-by-step process. (I have a host and everything, so that’s already taken care of.) Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:17:23+00:00Added an answer on May 19, 2026 at 9:17 am

    To do it without a page load (i.e. immediately after the button click), you’ll have to do it in Javascript (working jsfiddle example here)

    <a id="myButton" href="#">
        click here to get random stuff
    </a>
    
    <div id="myRandomDiv">
    </div>
    
    <script type="text/javascript" charset="utf-8">
        var randomStrings = [
            "hello 1",
            "hello 2",
            "hello 3", 
            "hello 4",
            "hello 5",
        ];
    
    
    
        var randomDiv = document.getElementById("myRandomDiv");
    
        document.getElementById("myButton").addEventListener("click", function() {
              randomIndex = Math.ceil((Math.random()*randomStrings.length-1));
              newText = randomStrings[randomIndex];
              randomDiv.innerHTML = newText;
        });
    </script>    
    

    To do this instead in PHP (which will require a new page load), you could do this:

    <?php
    
    
    $randomThings = array(
        'random thing 1',    
        'random thing 2',    
        'random thing 3',    
        'random thing 4',    
        'random thing 5',    
        'random thing 6',    
        'random thing 7 ',    
    );
    
    ?>
    
    
    
    
    <!-- REST OF YOUR PAGE -->
    
    <?php
    
    echo $randomThings[mt_rand(0,count($randomThings)-1)];
    
    ?>
    
    <!-- OTHER STUFF -->
    

    First, we create an array (‘list’) of random things and store it in the variable $randomThings.

    Elements in an array can be accessed using $variableName[$index] — in this case, the indices will simply be 0,1,2,3,4,5,6.

    The reason this one-liner (beginning with ‘echo’) works is, mt_rand is going to return a random number between 0 and 6, so it’ll grab a random element from the $randomThings array. echo will then spit it to the page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a web page, and I can't (with html code) add a draw
I am creating a web page that has 3 basic elements, select box, button,
I am creating web page using asp.net. Is it possible to remove/hide the browsers
When creating a new item - Web Form using Master Page I get a
Someone can explain this error? Error Creating Control - head Object reference not set
I'm creating a web page which gets records from a database, these records are
I'm creating a web page, when opened in iphone safari browser, a cookie will
What are the basics for creating a web page for a mobile device? I'm
I'm creating a web page for a kiosk at a building entrance, so there
Have small web page at www.peterbio.com/mom/test.htm Someone wrote the code with mouse over and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.