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>&nbsp;</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,

However, it works fine with other html tags and/or simple text. Has anyone experience this before? If yes, please let me know how you resolved it.

Thanks for your help.

-Phil-


In reply to Compare Textarea Value to Hidden Field Value by phildeman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.