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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:42:50+00:00 2026-06-01T00:42:50+00:00

When the user enters his/her MerryParentEmail address, the corresponding name should be fetched fr

  • 0

When the user enters his/her MerryParentEmail address, the corresponding name should be fetched fr the database and displayed in the MerryParentName input textbox. I have already tried doing this with ajax, jquery and php and it worked. But now, the corresponding name is not getting displayed when i use ajax, jquery and cakephp.

The alert outputs: data%5BMerryParent%5D%5Bemail%5D=b

Can someone point out on where i’m going wrong? Thank you.

default.ctp (layout file)

<script type="text/javascript">
  $(document).ready(function(){
  $("#MerryParentEmail").keyup(function(){
    //txt=$("#MerryParentEmail").val();
    txt=$("#MerryParentEmail").serialize();
    alert(txt);
    $.post("../merry_parents/getname",txt,function(result){
      $("#MerryParentName").val(result);  
    });
  });
});
 </script>

view.ctp

<?php
echo $this->Session->flash();
//echo $this->Form->create('MerryParent', array('default'=>false));
echo $this->Form->create('MerryParent');

echo '<fieldset>';
echo '<legend>Parent Information</legend>';
echo $this->Form->input('MerryParent.email');
/*if (isset($name))
   echo $this->Form->input('MerryParent.name', array('label'=>'Parent/Guardian Name','value'=>$name));
else*/
   echo $this->Form->input('MerryParent.name', array('label'=>'Parent/Guardian Name'));

echo '</fieldset>';

//echo $this->Form->end('Submit');

 ?>

merry_parents_controller.php

<?php
 class MerryParentsController extends AppController{
public $many_children_flag='false';
var $name='MerryParents';

function beforeFilter()//executed before any controller action logic
{   parent::beforeFilter();
    $this->Security->validatePost=false;  //set to false to completely skip the validation of POST request
        //parent::beforeFilter();
    if(isset($this->Security) && $this->RequestHandler->isAjax()){
        $this->Security->enabled = false;
        Configure::write('debug', 0);
        $this->autoRender=false;
        }   
}

function getname(){
 if (!empty($this->data)){
    //var_dump($this->data);

    $merryparent_info=$this->MerryParent->getMerryParents($this->data['MerryParent']['email']);
    //print_r($merryparent_info);
    $name=$merryparent_info['MerryParent']['name'];
    $this->set('name',$name);
    //$this->render('/merry_parents/ajax_input');
    }
}
function view(){
    //$name='';
    //var_dump($this->data);
    //$this->getname();
}

merry_parent.php model

function getMerryParents($field_value){
    if (is_int($field_value))
        $conditions=array('merryParent.id'=>$field_value);
    else
        $conditions=array('merryParent.email'=>$field_value);

    //debug($conditions);

    $merryparent_info=$this->find('first',array(
                                'conditions'=>$conditions,
                                'recursive'=>-1   //fetches merry_parents table data only not the associated data
                                ));

    //debug($merryparent_info);
    return $merryparent_info;
}
  • 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-01T00:42:52+00:00Added an answer on June 1, 2026 at 12:42 am

    Try:

    
    //add
    $this->layout = false;  
    //and instead of setting name simply echo the name from your function, like
    echo $name;
    

    Hope that helps

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

Sidebar

Related Questions

All, I have made my own website where the user enters his/her address. Based
After the user enters his / her license key, my application activates itself with
In my application, I have a food activity in which the user enters his/her
Write a program that asks the user to enter his or her first name
Here is the scenario: User enters the registration page. After filling out his/her details
I am trying to remove an Entry field after a user gives his/her name,
I am looking to prompt the user to enter his/her name at the beginning
I have a online shopping cart, at checkout user enters his zipcode. There are
In case a user forgets to enter an input area or enters an invalid
I've developed a dialog box that prompts a user to enter his/her phone number

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.