0
$('#update').val();

is not working how do it?thk

i want remove data in textarea WHEN submit

<script type="text/javascript" src="../nicEdit.js"></script>
<script type="text/javascript">
    bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
</script>
<form id="submit">
<textarea name="area1" id="update" cols="40"></textarea>
<input type="button" id="saveResult" value="Save All Data" />
<div id="displayResult"></div>
<script>
$(document).ready(function() {
    $("#saveResult").click(function() {
        //nicEditors.findEditor('update').saveContent();
        var nicE = new nicEditors.findEditor('update');
        firstname = nicE.getContent();
        lastname = $("#lname").val();
        $.post("re.asp",{ update2: firstname, LName2: lastname },function(data) {
            $('#displayResult').append(data);
        });
        $('#update').val();
        $('#lname').val('');
    });
});
</script>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
user2484507
  • 21
  • 1
  • 2
  • 2
    you really should work on formatting the codes..anyways to set an empty value .it should be `$('#update').val('');` – bipen Jun 17 '13 at 07:44
  • But @Salman_A please do not indent the CODE 4 spaces from the script tag. It makes the indentation so deep we always have to scroll. – mplungjan Jun 17 '13 at 07:46
  • yes really you can try with nicedit.com richtext editor – user2484507 Jun 17 '13 at 07:52

5 Answers5

3

Try this:

nicEditors.findEditor( "update" ).setContent( 'value for textarea' );//set value

or

nicEditors.findEditor( "update" ).setContent( '' );//set empty
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
1

You can try this,

var nicE = new nicEditors.findEditor('update');
nicE.setContent('');

let me know for further help

Mayur Borad
  • 1,295
  • 9
  • 23
  • For refrence http://stackoverflow.com/questions/5207503/how-do-i-get-the-contents-of-a-nicedit-form-when-submitting-trough-ajax – Mayur Borad Jun 17 '13 at 07:52
0

The val() method on input gives the value .It wont set the value.

You have to use

$('#update').val(''); //sets empty val in text area

or

$('#update').val('someDataString'); //sets the string what ever you have

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
0

Keep in mind, that you could reset a form easily via:

document.forms[0].reset()

So when you do not only want to reset one specific area, but have to clear a complete form, it would be woth considering.

Thomas Junk
  • 5,588
  • 2
  • 30
  • 43
0

use this, simple and easy

$("div.nicEdit-main").html('');

For updating Nicedit you can write

$("div.nicEdit-main").html('<h1>Test</h1>');
panky sharma
  • 2,029
  • 28
  • 45