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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:01:40+00:00 2026-06-10T23:01:40+00:00

I need button to begin a mysql query to then insert the results into

  • 0

I need button to begin a mysql query to then insert the results into a javacript code block which is to be displayed on the same page that the button is on. mysql queries come from the values of drop-down menus.

Homepage.php contains

two drop down menus

div id='one' to hold the results javscript code block

a button to stimulate the mysql query to be displayed in div id ='one' through Javascript

flow of the process is as such
1. user chooses an option from each drop down
2. when ready, the user clicks a button
3. the onclick runs a mysql query with selections from the drop down menu.
4. send the results as array from the mysql query into the javascript code block
5. display the results in div id ='one'

all of this needs to happen on the same page!

The problem I am having is that as soon as the page is loaded, the javascipt is static. I am unable to push the mysql results into the javascript on the page which I need it to appear on. Having everything on the same page is causing trouble.

I’m not looking for the exact code laid out for me, just a correct flow of the process that should be used to accomplish this. Thank you in advance!

I’ve tried

using both dropdowns to call the same javascript function which used httprequest. The function was directed towards a php page which did the mysql processing. The results were then return back through the httprequest to the homepage.

I’ve tried to save the entire Javascript code block as a php variable with the mysql results already in it, then returning the variable into the home page through HTTPRequest, thinking I could create dynamic javascript code this way. Nothing has worked

  • 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-10T23:01:42+00:00Added an answer on June 10, 2026 at 11:01 pm

    You need to use a technology called AJAX. I’d recommend jQuery’s .ajax() method. Trying to do raw XHR is painful at best.

    Here is how you’ll want to structure your code:

    1. Load the page.
    2. User chooses an option.
    3. An onChange listener fires off an AJAX request
    4. The server receives and processes the request
    5. The server sends back a JSON array of options for the dependent select
    6. The client side AJAX sender gets the response back
    7. The client updates the select to have the values from the JSON array.

    Basically, HTTP is stateless, so once the page is loaded, it’s done. You’ll have to make successive requests to the server for dynamic data.

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

Sidebar

Related Questions

I need to create a caption bar button for a CDockablePane which will call
I need a button-like control that can have a Checked property, so that when
I need the button submit to be disabled unless JavaScript is on. I tried:
I need a button that takes login for certain user without entering the password.
I am using Struts2,(jsp) to design page , I need three button on sing
I need to create button programatically with an image for normal and highlighted state
I have a ListView that displays a link button. I need the link button
I have some 10 buttons with different names each.On selecting each button I need
Need to set some attributes of button. For example Checked. I guess it is
I need to put a button in the bottom right of an otherwise empty

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.