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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:58:45+00:00 2026-06-04T11:58:45+00:00

How can I run a PHP query which only runs when an option is

  • 0

How can I run a PHP query which only runs when an option is chosen from a select dropdown but also which refreshes each time a different option is chosen?

For example, here is the HTML:

<html>
<head>
<script type="text/javascript" src="/hr/includes/jui/js/jquery-ui-1.8.20.min.js"</script>
<script>
$(document).ready(function() {
    $('#select_box_1').change(function() {
       if($(this).val() != '')
        $.ajax({
            type: 'get',
            url: 'balance1.php',
            data: 'value' + $(this).val() ,
            success: function(data) {
                $("#result-div").html(data);
            }
        });
     }
    });
});
</script>
</head>

<body>

<form name="form" id="form" method="post" action="validate.php">

<div id="select_box_1">
<select name="drop_down">
<option value="">Please choose</option>
<option value="1">John</option>
<option value="2">Bob</option>
<option value="3">Mike</option>
</select>
</div>

<div id="result-div">

</div>

<input type="submit">

</form>

</body>

</html>

balance1.php

<?php 
print "GET Value:".$_GET['value'];
?>

I would like to run a query below the select box depending on the value chosen – for example, when nothing is chosen there is no query ran. If the user chooses John from the list then the query runs where the id=1 and displays results for John. If the user then chooses Bob, the query should run again where the id=2 and so on?

  • 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-04T11:58:46+00:00Added an answer on June 4, 2026 at 11:58 am

    This is working:

    [...]
    <select name="drop_down" id="sel_something">
    [...]
    
    $('#sel_something').change(function() {
        if($(this).val() != '') {
            $.ajax({
                type: 'get',
                url: 'someurl',
                data: { 'value' : $(this).val() } ,
                success: function(data) {
                    // do your stuff
                }
            });
        }
    });
    

    I gave an id to the select and modified the data line (and added a few syntax corrections).

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

Sidebar

Related Questions

I have a mysql SELECT query which is fast (<0.1 sec) but only the
Right now I can run a PHP script from my Mac terminal like echoing
I can run multi-queries with MYSQL v5 with extension PHP :mysqli. But with MYSQL
I have this query which I run in phpMyAdmin SELECT m.msgFrom, m.msgTo, m.msgID, m.subject,
I can run my script just fine from the command line: php test.php and
Can I run a PHP CGI script as a background process using exec() ?
Can you run some script before the uploading of a file starts in php?
So, I can run the following statements from within mysql itself successfully. SET @fname
We have an PHP/MySQL application where the users can create their own databases, which
<?php $id = $_SESSION['user_id'] ; echo <form method='post' action='#'>; echo </select> <p>Which Hospital Would

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.