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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:57:28+00:00 2026-06-13T12:57:28+00:00

I’m looking for a solution/best practice for the following issue. I have a page

  • 0

I’m looking for a solution/best practice for the following issue.

I have a page with an HTML form with one dropdown list and a submit button. Underneath of the dropdown box is an empty space that I would like to populate with form inputs based on the selected value in the dropdown box. Im thinking this can be done in JavaScript but I would much prefer a PHP/client side solution if possible.

Example HTML:

<form name="initialdropdown" action="#" method="post">
    <select name="action">
    <option value="default">--select--</option>
    <option value="a">Option 1</option>
    <option value="b">Option 2</option>
    <option value="c">Option 3</option>
    <option value="d">Option 4</option>
    </select>
    <input type="submit" name="submit" value="submit"></input>
</form>

I’ve explored calling this php script from the form action:

    <?php

    $getOption = $_POST['action'];
    $addUrl = $getOption.".php";

    include $addUrl;
    header("Location: htmlpage.php");

    ?>

and then create several different php files (a.php,b.php,c.php, etc. In each of the files then including the HTML form that I would like to echo out wrapped in a function, and including the function in the main HTML page. I do not feel comfortable that this is a good way to do it. Can anyone shed some light on the best way to go about this?

  • 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-06-13T12:57:29+00:00Added an answer on June 13, 2026 at 12:57 pm

    If you want to display something on the HTML form that updates as you pick different options, JavaScript is the natural choice because you don’t have to go and make requests to the server which means moving around data and waiting for responses. JavaScript can simply change the page as many times as you want while the user interacts with the page.

    However, if you are dead set on generating whatever you want to display on that form with PHP, you could have PHP output the display information to the page right into the JavaScript. Then the JavaScript displays this data from PHP. Or, you can use an AJAX call to PHP to request the data to display each time a different option is chosen.

    update

    Given your latest comment, you could very easily set up more form options without using PHP. In the HTML set up all the various form options you might want to show, but hide the optional parts with CSS. Then reveal each section as needed with a little JavaScript. jQuery can make this even easier.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites 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.