I am certainly not an ajax expert, but should your method not receive
the chosen id from the drop down list?
I ask, because based on the code you have shown, I don't see how the
id gets delivered to your "populate_document_select" action in your
controller.
Should your action not be defined as:
[code]
function populate_document_select( $document_type_id = null ) {
...
}
[/code]
Enjoy,
John
On May 11, 6:57 am, aveev <[email protected]> wrote:
> I'm new to using ajax helper.
> I'm designing a travel document that uses 1 drop down and 1 text field in a
> page.
> The drop down lists the travel document types and the text field will
> display the most current unused travel document according to the travel
> document type being selected.
> I tried to use observe field, but I don't know how to display it the fetched
> field from db to text field.
> Here's the code:
> document.ctp
> <?
> echo $form->create('');
> echo
> $form->select('document_type_id',array($docTypes),null,array('id'=>'document'),true);
>
>
> //this form field will output the recent document number
> echo $form->input('document_number', array('id'=>'docnum'));
>
> echo
> $ajax->observeField('document',array('url'=>'populate_document_select','update'=>'docnum'));
> echo $form->end('Save');
>
> ?>
>
> DocumentsController
> function test_ajax() {
> $docTypes = $this->DocumentType->find('list');
>
> $this->set(compact('docTypes'));
> }
>
> function populate_document_select() {
> //this function will return most current unused doc number
> $doc =
> $this->Document->find('first',array('conditions'=>array('Document.document_type_id'=>$document_type_id,'status'=>'new'),
> 'fields'=>(array('Document.document_number'))));
>
> return $doc['Document']['document_number'];
> }
>
> Any help will be greatly appreciated.
> Thanks
> I use cake php 1.2
> --
> View this message in
> context:http://old.nabble.com/Using-ajax-observefield-method-to-update-text-f...
> Sent from the CakePHP mailing list archive at Nabble.com.
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> athttp://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en