wysiwyg data not preserved when using java execute post method for a form

Discussion in 'JavaScript' started by stevejoseph, Feb 5, 2009.

  1. #1
    I have tried 2 different wysiwyg editors now but get the same problem.
    When i use a wisiwyg editor within a form containing several elements (e.g text, radio button etc) i can pass all the form elements to another page no problem when the forms submit is clicked.

    However when i use a 'button' and call a java script to validate the other elements and then execute the post with java, i find that the wysiwyg data is empty upon attemtping to retreive it after the post:-(

    My code:
    <script language="javascript" type="text/javascript">

    function exepostandvalidate(){

    //....
    //do lost of java validation here ....
    //....

    //I have tried setting a hidden field but still does not work
    //use a hidden field to transfer the wysiwyg info
    //document.test.hiddenwysiwyg.value = document.getElementById("textarea1").innerHTML;

    //submit the form
    document.forms['test'].submit();
    }

    </script>


    <form name="test" method="post" action="additemtodb.php" enctype="multipart/form-data">

    .........
    <input name="itemname" type="text" id="itemname" size="50" maxlength="100">
    <input name="detail1" type="text" id="detail1" size="50" maxlength="100">
    ............




    <script language="JavaScript" type="text/javascript" src="wysiwyg.js">
    </script>
    <textarea id="textarea1" name="test1" style="height: 170px; width: 500px;">

    </textarea>
    <script language="javascript">
    generate_wysiwyg('textarea1');
    </script>

    <input type="hidden" name="hiddenwysiwyg" id="hiddenwysiwyg" />
    <!--<input type="submit" value="test"/>THIS WORKS BUT I LOOSE MY VALIDATION-->
    <input name ="testbutton" type="button" value="submit" onclick="exepostandvalidate()">
    <!--DOES NOT WORK-->
    </form>


    Please can anyone help or give me some ideas or alternatives
     
    stevejoseph, Feb 5, 2009 IP