[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Returning multiple values with CGI::Ajax


Maybe I'm misreading what's you're trying to do, but if the user changes the date in one form, why not just distribute that value to the other two formfields with Javascript? You could do this with a CGI::Ajax callback if you wanted to have the server check the date first. I don't think CGI::Ajax was intended to deal with the multiple elements in the DOM, except via JavaScript.

Bruce


Jonathan Mangin wrote:
Hi all,

Here's another semi-OT CGI::Ajax question.  Hoping someone has
solved this with CGI::Application.  I have three forms on
a page.  Form1 has a date field.  In one of my run modes, if
the user changes that date, I want to replace hidden fields
in the other two forms with the new date.  I'm sending one
element and (hopefully) returning two to distinct divs.

In the run mode:
my $pjx = new CGI::Ajax('selected_date' => 'test.pl?rm=selected_date');
# $pjx->DEBUG(1);
# $pjx->JSDEBUG(1);
my $ajax_js = $pjx->show_javascript();

In the template:
[% IF ajax_js %]
   <input class=text type=text id=date name=date size=11 maxlength=10
value=[% i_row.0 %] onblur="selected_date(['date'], ['form2_date',
form3_date']);">
[% ELSE %]
   <input class=text type=text name=date size=11 maxlength=10 value=[%
i_row.0 %]>
[% END %]

The sub:
sub selected_date {
   my $self = shift;
   my $q = $self->query();
   my $date = $q->param('date');

   my $form2 = "<input type=hidden name=date value=$date>";
   my $form3 = "<input type=hidden name=date value=$date>";

   return ($form2, $form3);
}

<div id=form3_date> always displays 'undefined' so I'm not sure
where this is going wrong.  <form2_date> is populated correctly.
Does anyone see anything obviously wrong?

Thanks,
Jon



---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed





---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.