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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:15:17+00:00 2026-05-25T15:15:17+00:00

I am a PHP beginner and today I started learning Mootools. I am experimenting

  • 0

I am a PHP beginner and today I started learning Mootools. I am experimenting with a autocomplete search-box that sends out an array after you submit the form. You can type multiple names and search for all of them.

What I’m trying to do is to take that array in mootools, send it to PHP and display the results without leaving the page.

Here is the original file

// Autocomplete initialization
var t4 = new TextboxList('form_tags_input_3', {unique: true, plugins: {autocomplete: {}}});

// sample data loading with json, but can be jsonp, local, etc. 
// the only requirement is that you call setValues with an array of this format:
// [
//  [id, bit_plaintext (on which search is performed), bit_html (optional, otherwise plain_text is used), autocomplete_html (html for the item displayed in the autocomplete suggestions dropdown)]
// ]
// read autocomplete.php for a JSON response example

t4.container.addClass('textboxlist-loading');               
new Request.JSON({url: 'autocomplete.php', onSuccess: function(r) {
  t4.plugins['autocomplete'].setValues(r);
  t4.container.removeClass('textboxlist-loading');
}}).send();     

Here’s autocomplete.php

$response = array();
$names = array('Some name', 'Some name 2', 'etc');

// make sure they're sorted alphabetically, for binary search tests
sort($names);

foreach ($names as $i => $name)
{
    $filename = str_replace(' ', '', strtolower($name));
    $response[] = array($i, $name, null, '<img src="images/'. $filename . (file_exists('images/' . $filename . '.jpg') ? '.jpg' : '.png') .'" /> ' . $name);
}

header('Content-type: application/json');
echo json_encode($response);

Submit.php

<?php
print_r($_POST);
?>

And here is what I did

My php:

<?php
$result['msg'] = print_r($_POST);

echo json_encode($result);
?>

And here are the changes I made in the index2.php file:

<input type="submit" name="submitform" value="Submit" id="submitform" />
<p id="response"></p>  

$('#submitform').addEvent('click', function(){

  new Request.JSON({  
        url: "inc/php/json.php",  
        onSuccess: function(response){  

        $('response').set('html',+data.result);  

        }  
    }).get($('findnames')); 


});

When you press submit, nothing happens, so obviously I made an error somewhere that I can’t seem to figure out.

  • 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-25T15:15:17+00:00Added an answer on May 25, 2026 at 3:15 pm
    $result['msg'] = print_r($_POST);
    

    you cannot do this, print_r directly prints the array contents to page, so you cannot store it in variable.

    Maybe you would use this:

    <input type="button" onclick="SomeFunction(); name="submitform" value="Submit" id="submitform" />
    

    Just change SomeFunction(); to something else.

    EDIT:
    I checked Chrome error console and here´s what it says:

    Uncaught TypeError: Cannot call method 'addEvent' of null
    

    So #submitform seems not to be valid in some reason. Please try my function thing to make it work like it should.

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

Sidebar

Related Questions

This is a topic that, as a beginner to PHP and programming, sort of
I am beginner in PHP and i read in manual that $_REQUEST is a
I'm a beginner in PHP. So far, from the source I'm learning from, the
I am a beginner. I am using Aptana Studio for PHP. Today, I also
I went to an interview early today and it came out that I don't
I am a PHP beginner. I have developed a social networking website similar to
I am a PHP beginner and saw on the forum this PHP expression: My
I am beginner in PHP. I am trying to parse this xml file. <relationship>
I'm a beginner with PHP security issues. Someone reported a security issue with my
i'm a beginner to php. i need to use php function which process some

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.