Hi,
I hope I can get help with this problem I have.
I am trying to compare the value in a textarea to the value in a hidden field. I am doing this to avoid updating the DB table, if there are no changes. The data is stored in a MySQL table. I am using DBIx::Class to interact with the MySQL table.
Initially, I retrieve the data from the database and populate the textarea in a form. In addition, I assign the same value in a hidden field to do a comparison, later. If the textarea contains bullets, it will not return the appropriate return value.
I am using Catalyst with Mason. In addition I am using CKEditor with the textarea fields.
HTML CODE
. . . <td>Attending:</td> <td><textarea class="ckeditor" name="attending_msg" id="attendin +g_msg"><% $obj->attending_msg %></textarea></td> </tr> <tr> <td>Not Attending:</td> <td><textarea class="ckeditor" name="notattending_msg" id="nota +ttending_msg"><% $obj->notattending_msg %></textarea></td> </tr> <tr> <td colspan="2"> <p> </p> <input type='hidden' name='o_attending_msg' value="<% $obj +->attending_msg %>"> <input type='hidden' name='o_notattending_msg' value="<% $ +obj->notattending_msg %>"> </td> </tr> . . .
PERL CODE
method set_email_content($params, $username) { my $dt = $self->get_datetime(); my $posted_on = $dt->ymd . " " . $dt->hms; if(($params->{ 'attending_msg' } eq $params->{ 'o_attending_msg +'}) && ($params->{ 'notattending_msg' } eq $params->{ 'o_notattendi +ng_msg' })) { return 0; } else { my $obj = $schema->resultset( 'MyTable' )->search({ MID => + 1})->single; $obj->attending_msg( $params->{ 'attending_msg' } ); $obj->notattending_msg( $params->{ 'notattending_msg' } ); $obj->updated_by( $username ); $obj->updated_on( $posted_on ); $obj->update; return 1; } }
If I submit the form, with unchanged values it continues to update the database, because it assumes the textarea value is not equal to the hidden field value. This only happens when there is an unordered list,
Thanks for your help.
-Phil-
In reply to Compare Textarea Value to Hidden Field Value by phildeman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |