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 3759804
In Process

The Archive Base Latest Questions

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

I would like some help in starting this project, some advice on where to

  • 0

I would like some help in starting this project, some advice on where to look. On one of my sites we have a jQuery Tools powered overlay that holds a contact form. The form is located in the /forms directory. I would like to create several (5-6) forms that have different layouts and test which works best with our users.

I think that creating a “control” file in php, and linking to it instead of directly to a form to pull in a random form would work.

I am not sure about the code, but know that I need to:
– read the directory with opendir and readdir?
– add FILES to an array (use is_dir )
– generate a random number between 0 and the count() of the array
– include the specified random file.
– call this function on the click event of the link either inline or jQuery

Would I do this in a separate file? Any advice is much appreciated. Let me know if I need to clarify or add more details.

Thank you.

  • 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-19T10:22:24+00:00Added an answer on May 19, 2026 at 10:22 am

    Sounds like you definitely have the right idea. This should be about right, almost exactly as you outlined it. Unless you have a need to load this up with jQuery after initial page load, I’d recommend doing it in the PHP during initial page load.

    adapted from readdir(), example 2:

    // load random form
    $fileList = array();
    if ($handle = opendir('./forms')) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                $fileList[] = $file;
            }
        }
        closedir($handle);
    }
    
    $randIndex = array_rand($fileList);
    include './forms/' . $fileList[$randIndex];
    

    Note: This code assumes that the
    forms directory only contains form files and no other files or
    directories that need to be excluded.

    Also, if you need to capture the file’s output in a string rather than print it directly to the browser, see include, example 6.

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

Sidebar

Related Questions

I'm starting up a new jsf2/jQuery project, and would like to use the a4j:jsfunction
I would like to show some hidden text in a Flex application and have
I am starting a c++ project which I would like to compile equally well
I would like some help adding in a POCO .tt Entity Framework template Attributes
I am trying to rewrite some legacy C code and would like to have
I would like some help with a problem. In Python: a=array([2,2]) b=ones((2,10)) I would
I'm in the process of learning LINQ and would like some help the following
I'm writing a small application in VB.NET and I would like some of the
We are designing a new database and I would like some input in where
I need to generate random text strings of a particular format. Would like some

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.