Ok i need a bit of help cause I'm rely stuck here. This is the code I currently use to update my DB:
Basically this just takes the name, email and user comment, checks if they are blank or not and sends them to the DB without loading the page. The PROBLEM is that the text in the textarea is not seen by my script and stops the posting process. So how can I inject the text value from the textarea in this case!?
<script type="text/javascript" src="js/ckeditor.js"></script> <script type="text/javascript"> $(function() { $(".submit").click(function() { var name = $("#name").val(); var email = $("#email").val(); var comment = $("#comment").val(); var dataString = 'name=' + name + '&email=' + email + '&comment=' + comment; if(name=='' || email=='' || comment=='') { alert('Please Give Valide Details'); } else { $("#flash").show(); $("#flash").fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle"> <span class="loading">Loading Comment...</span>'); $.ajax({ type: "POST", url: "commentajax.php", data: dataString, cache: false, success: function(html){ $("ol#update").append(html); $("ol#update li:last").fadeIn("slow"); document.getElementById('comment').value=''; $("#comment").focus(); $("#flash").hide(); } }); } return false; }); }); <form action="#" method="post"> <p> <input type="hidden" name="title" value="seul" id="name"/> <input type="hidden" name="email" value="seularts@gmail.com" id="email"/> <!-- Adauga text! --> <textarea id="comment" name="comment"> </textarea> <script type="text/javascript"> //<![CDATA[ CKEDITOR.replace( 'comment', { toolbar : 'Basic', extraPlugins : 'autogrow' }); (function() { CKEDITOR.plugins.autogrow = { getHeightDelta : function( editor ) { var contents = CKEDITOR.document.getById( 'cke_contents_' + editor.name ); var outer = contents.getAscendant( 'table' ).getParent().getParent().getParent(); // Get the height delta between the outer table and the content area. var delta = ( outer.$.offsetHeight || 0 ) - ( contents.$.clientHeight || 0 ); return delta; }, getEffectiveHeight : function( height ) { if ( height < CKEDITOR.config.autogrow_minheight ) height = CKEDITOR.config.autogrow_minheight; else { var max = CKEDITOR.config.autogrow_maxheight; if ( max && max > 0 && height > max ) height = max; } return height; } }; function checkSize ( evt ) { var editor = evt.editor; var delta = plugin.getHeightDelta(editor) ; var $body = editor.document.$.body; if(delta != 0){ var newHeight = delta + $body.offsetHeight; newHeight = plugin.getEffectiveHeight( newHeight ) ; var contents = CKEDITOR.document.getById( 'cke_contents_' + editor.name ); newHeight = Math.max( newHeight, 0 ) + 'px'; if(contents.getStyle('height') != newHeight) { contents.setStyle( 'height', newHeight ); } } }; var plugin = CKEDITOR.plugins.autogrow; CKEDITOR.plugins.add( 'autogrow', { init : function( editor ) { editor.on( 'insertHtml', checkSize ); editor.on( 'insertElement', checkSize ); editor.on( 'selectionChange', checkSize ); editor.on( 'instanceReady', checkSize ); } } ); })(); CKEDITOR.config.autogrow_maxheight = 0; CKEDITOR.config.autogrow_minheight = 50; //]]> </script> <br /> <input type="submit" class="submit" value=" Submit Comment " /> </p> </form> </script>
Basically this just takes the name, email and user comment, checks if they are blank or not and sends them to the DB without loading the page. The PROBLEM is that the text in the textarea is not seen by my script and stops the posting process. So how can I inject the text value from the textarea in this case!?