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

  • Home
  • SEARCH
  • 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 5936085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:20:55+00:00 2026-05-22T15:20:55+00:00

I need some help please. I need to create a drop down list and

  • 0

I need some help please. I need to create a drop down list and then when the option is submitted a php script must run. The complication is I can’t hard code any of the values. I need it to be ‘dynamically created’

config.php

$number_Of_Option="3"

$Option_One_Name="Cars"
$Option_One_Year="2000"
$Option_One_Colour="Blue"

$Option_Two_Name="Houses"
$Option_Two_Year="2003"
$Option_Two_Colour="Pink"

$Option_Three_Name="Bikes"
$Option_Three_Year="1990"
$Option_Three_Colour="Orange"

Now I need the drop down to be made with the name in the drop down to be “Cars”, “Houses”, “Bikes” but they must be variable based so if I change “Cars” it will change.

Then when the option is submitted (Option Two in this case) I need $Option_Two_Year and $Option_Two_Colour to be passed to a script where these two variables are the variables in the script. So the script is always the same however if drop down one is selected then it uses variables 1 if 2 then it uses variables 2 etc. I also need to it work for an infinite number of options so at any time I can got into the config.php and add another option with its own variables. It can use arrays and jquery if that’s easier or necessary.
Thanks

  • 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-22T15:20:56+00:00Added an answer on May 22, 2026 at 3:20 pm

    Make an external file, eg. options.php, with this code:

    $options = array();
    $options["cars"] = array("2000","blue");
    $options["houses"] = array("2003","pink");
    $options["bikes"] = array("1990","orange");
    

    Include this file in both the form page, and the parse script, using include("options.php");

    In the form page, do:

    include("options.php");
    echo '<select name="option">';
    foreach($options as $name => $values)
    {    echo '<option value="' .$name .'">' .$name .'</option>';
    }
    echo '</select>';
    

    In the parse script, do:

    include("options.php");
    $chosenValue = $_POST['option'];
    list($year,$colour) = $options[$chosenValue];
    

    Now $year and $colour will contain the year and colour for the option with the chosen name.

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

Sidebar

Related Questions

I need some help in PHP to create short urls just like StackOverflow creates
I am getting a little confused and need some help please. Take these two
I need some help from the shell-script gurus out there. I have a .txt
I need some help with jQuery script again :-) Just trying to play with
Hi I need some help with the following scenario in php. I have a
I need some css and syntax help,please. Your help is warmly welcome. I want
I need some help with sorting a multidimensional array in php. I need the
I need some help regarding algorithm for randomness. So Problem is. There are 50
I need some help calculating Pi. I am trying to write a python program
I need some help ... I'm a bit (read total) n00b when it comes

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.