tags:

views:

45

answers:

1

I am using this jQuery based jWysiwyg.
http://code.google.com/p/jwysiwyg

How do I pass the value of $('#wysiwyg').val() to php script. For example to show the value of jwysiwyg in an alert box, I am using

<form name="form1" method="post" action="sendmail.php">
    <textarea name="wysiwyg" id="wysiwyg" rows="5" cols="103"></textarea>
    <input type="submit" name="Submit" value="Login"></input>
    <input type="button" value="Alert HTML" onclick="alert($('#wysiwyg').val());" />
</form>

What I need is how to pass value of jwysiwyg's value in submit control and how do I call "logout.php" on pressing of a button?

A: 

Something like:

<form name="form1" method="post" action="sendmail.php" id="sendmailform">
    <textarea name="wysiwyg" id="wysiwyg" rows="5" cols="103"></textarea>
    <input type="submit" name="Submit" value="Login"></input>
    <input type="button" value="Alert HTML" onclick="$('#sendmailform').attr('action','logout.php').submit();" />
</form>

There is always the option to do is in more of an ajax way, of using $.post (http://api.jquery.com/jQuery.post/)

$.post('logout.php', { "val": $('#wysiwyg').val() }, function(response) {
  alert('response')
});
halkeye