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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:26:21+00:00 2026-05-20T10:26:21+00:00

i need a tips, how to make a AJAX request with mootools, when some

  • 0

i need a tips, how to make a AJAX request with mootools, when some value from a dropdown list is selected, i mean to catch this event + make a ajax request to a external php page. And on this php page i need to run a mysql query. Thanks.

<form name ="f1" action=""> 
     <select id="myr" NAME ="s1" onChange = "GetSelectedItem()"> 
          <OPTION VALUE = "meshed" selected >-- Please Select --</OPTION> 
          <OPTION VALUE = "girls">Male seeking Female</OPTION> 
          <OPTION VALUE = "mens">Female seeking Male</OPTION> 
          <OPTION VALUE = "mens">Male seeking Male</OPTION> 
          <OPTION VALUE = "girls">Female seeking Female</OPTION> 
     </select> 
</form>

php

$dbhost = 'localhost'; 
$dbuser = 'root'; 
$dbpass = ''; 
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');     
$dbname = 'ratings'; 
mysql_select_db($dbname) or die('Error connecting to database'); 
$sql = "TRUNCATE TABLE rabid_ratings"; 
$re = mysql_query($sql) or die(mysql_error()); 
echo "done";

mootools

<script type="text/javascript">
      window.addEvent('domready',function(){
          var myRequest = new Request({
               url: 'truncate.php',
               method: 'post',
               onRequest: function(){
               },
               onSuccess: function(responseText){
                    alert("done!"+ responseText);
               },
               onFailure: function(){
                    alert("failed");
               }
          });

          $('myr').addEvent('change', function(event){
               event.stop();
               myRequest.send();
          });
      });
</script>
  • 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-20T10:26:22+00:00Added an answer on May 20, 2026 at 10:26 am

    Add a change even to your select drop down. Let’s name the id of it “mydropdown”:

    $('mydropdown').addEvent('change', function(){
         //do your request (AJax) here
    });
    

    Here is the demo from Mootools. You can also use Request.HTML or Request.JSON depends on what you are seeking to return.

    Simple Request W/ Mootools

    Update: Example based off what you present

    First let’s see if your ajax is setup correctly by using the following simple ajax code. Once you get this working, then we can explore the PHP side. So, please try the following codes:

    html:

    <select id="myr" NAME ="s1"> 
        <OPTION VALUE = "meshed" selected >-- Please Select --</OPTION> 
        <OPTION VALUE = "girls">Male seeking Female</OPTION> 
        <OPTION VALUE = "mens">Female seeking Male</OPTION> 
        <OPTION VALUE = "mens">Male seeking Male</OPTION> 
        <OPTION VALUE = "girls">Female seeking Female</OPTION> 
    </select> 
    

    generic truncate php that echos whatever post var we send it:

    <?php
      echo $_POST['s1'];
    ?>
    

    Mootools, when on success should output “done! “:

    window.addEvent('domready', function(){
        var myRequest = new Request({
            url: 'truncate.php',
            method: 'post',
            onRequest: function() {
            },
            onSuccess: function(responseText) {
                alert("done! " + responseText);
            },
            onFailure: function() {
                alert("failed");
            }
        });
    
        $('myr').addEvent('change', function(event) {
            event.stop();
            var data = this.name + '=' + this.value;  //s1=<option value>, which is the post data we are sending to the php script
            myRequest.send(data);
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just need tips on how to make forms where request are submitted via AJAX
I really need some quick tips here. I've got this VBScript script which sends
I'm making a dictionary database in SQLite and need some tips. My SQL is
Hey all i am in need of some helpful tips/advice on how to go
I need to add some function that returns a value to a dom element.
I need to make some triangular buttons that overlap each other. While UIButtons can
I need to make a batch file that can copy files from one path
What are your best usability testing tips? I need quick & cheap.
Need a way to allow sorting except for last item with in a list.
need ask you about some help. I have web app running in Net 2.0.

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.