Thanks for your reply
I use mozilla firebug to see whether things work as I expect or not. I could
see that populate_document_select() function gets called and
data['Document']['document_type_id'] gets posted.
I can also get the expected return value (which is the most current unused
travel document number) from the response. What I don't know is how I can
set docnum field value.
What I should do might be similar like this (calling javascript code)
document.getElementById(docnum).value = $(return value from the response
object).
But I can't figure out how to do this exactly using ajax helper options.



John Andersen-6 wrote:
> 
> I suggest you use the Log to write out some debug information, to make
> sure that you work with the correct information.
> For example in the populate_document_select function I would do
> something like this:
> 
> [code]
> function populate_document_select() {
>    $this->log($this->data['Document'], 'ajax_debug_log');
>    $this->log($this->params, 'ajax_debug_log');
> ...
> }
> [/code]
> 
> Then look in the app/tmp/log directory for the log file and
> investigate the data there, whether they conform to your expected
> content.
> Enjoy,
>    John
> 
> On May 12, 4:18 am, aveev <nashrullah_a...@yahoo.com> wrote:
>> Sorry, the code I wrote should be like this, but it still doesn't work
>> test_ajax.ctp
>> <?
>>         echo $form->create('');
>> echo
>> $form->select('document_type_id',array($docTypes),null,array('id'=>'document'),true);
>>    
>>         echo $form->input('document_number', array('id'=>'docnum'));
>>
>> $ajax->observeField('document',array('url'=>'populate_document_select','update'=>'docnum'));
>>         echo
>> $ajax->observeField('document',array('url'=>'populate_document_select','update'=>'docnum'));
>>         echo $form->end('Save');
>>
>> ?>
>>
>> DocumentsController
>> function populate_document_select() {
>>           if(!empty($this->data['Document']['document_type_id'])) {
>>                 $options =
>> $this->getList($this->data['Document']['document_type_id']);
>>             $this->set('options', $options);
>>
>>           }
>>         }
>>
>> function getlist($document_type_id=null) {
>>
>>                         $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'];
>>
>>         }
>> populate_document_select.ctp
>> <?php
>> if (!empty($options)) {
>>   echo $form->input('document_number', array('id'=>'docnum',
>> 'value'=>$options));}
>>
>> ?>
> [snip]
> 
> 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php?hl=en
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Using-ajax-observefield-method-to-update-text-field-tp28519725p28532392.html
Sent from the CakePHP mailing list archive at Nabble.com.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to