hello, I loaded data from DB and print it in form: query = mysql_query("SELECT cont FROM `some_table` WHERE id = $id "); $index = mysql_fetch_array($query); $cont = $index['cont']; echo "<form method='post' action='index.php'> <textarea name='description' value='$cont'>$cont</textarea> </form>"; PHP: I want the script to compare the content of value $cont with the new text that I'll write in the TEXTAREA I need it to be on the client side, means - when I click SUBMIT, the script will be run and will giving me massage if the text in the TEXTAREA was change (not equal to value $cont). Thank you all in advanced, Roi.
echo "<script type='text/javascript'>"; echo "function chkSubmit() {"; echo " var cont = '$cont'"; echo " if (document.getElementById( 'description' ).value == cont) {"; echo " alert('Value matches');"; echo " //document.getElementById( 'formname' ).submit();"; echo " } else {"; echo " alert('Value does not match');"; echo " //document.getElementById( 'formid' ).submit();"; echo " }"; echo "}"; echo "</script>"; echo "<form method='post' name='formname' id='formid' action='index.php'><textarea name='description' id='description'>$cont</textarea>"; echo "<input type='button' name='process' value='Submit' onclick='javascript:chkSubmit();'/>"; echo "</form>"; Code (markup): Submit of the form is disabled, so if you want to submit the form in the case of match or a missmatch then just uncomment the submit line in javascript //document.getElementById( 'formid' ).submit(); by removing //
echo " //document.getElementById( 'formname' ).submit();"; Code (markup): should be echo " //document.getElementById( 'formid' ).submit();"; Code (markup): in line 6. Oops