How many bytes of 'corresponding text' will there be?  If it's not
many, why not just send them along with the initial page load and then
unhide the one you need or move it into mail_text.

If you really need to get something out of the database an ajax call
will work.

The ajax call causes jQuery to send a request to the server with a
call to a function in your controller.  jQuery then waits for the
server response.  The response can be a value to put into a target or
it can be another jquery function return a value or set of values.

You can find good examples in the book, chapter 10 under the heading
'The Ajax Function.'

<script>
jQuery(document).ready(function(){
  jQuery('#mail_subject').change(function(){
    subject=jQuery('#mail_subject').val();
    // ajax call goes here
    // let ajax set the value of 'mail_textQuery.
('mail_text').val(value);});
});

</script>

If you don't have Firebug, get it.  You'll need it to look at the
requests and responses.



On Aug 27, 2:52 am, annet <annet.verm...@gmail.com> wrote:
> Hi Cliff,
>
> Thanks for your reply. I fear I wasn't clear enough. I read about
> the .change and .val functions, however, I couldn't figure out how to
> get from the JavaScript function to querying the database and back to
> the JavaScript function.
>
> I have the following view:
>
> {{extend 'admincms/layout.html'}}
>
> <div class="box">
>   ...
>     {{=form}}
>   ...
> </div> <!-- box -->
> <script>
> jQuery(document).ready(function(){
>   jQuery('#mail_subject').change(function(){
>     subject=jQuery('#mail_subject').val();
>     value=...
>     jQuery.('mail_text').val(value);});});
>
> </script>
>
> Here ... based on subject the database should be queried for the
> corresponding text, which should then be put in the mail_text text
> area.
>
> Kind regards,
>
> Annet.

Reply via email to