One HTML Form, Two Submit Buttons, one to a pop up with POST data ... how?

Very new to JavaScript so I'm sorry if this is a daft question, I have searched for answers first and could not find anything that works for me ... so ..

The task:

One html form with two submit buttons. On submit (save changes) posts back to the same page and updates a database. The other submit button (preview) should open a pop-up showing what the data would look like if the user should press save.

My efforts so far:

This might not look like much of an effort but, trust me, I took a long time to get this far!

If you want to open a seperate window, you'll have to create a page (in php, for example) that views the info you throw at it via GET. I don't really recommend this, though, because there's a limit on how many characters you can send with GET (and especially on IE that limit is very low).
So, I would use AJAX. Same story, really, create a page that gives back the HTML for the text you throw at it (with POST), and put that HTML in a <div/>. It's easiest to look for a good AJAX library (for example jQuery, but perhaps it's a bit overkill as it includes much more than just AJAX).

I figured out the GET option ... two problems ... one input will often hold far too much data and also I have real difficulties reading the contents of that input because it is using something called TinyMce as a sort of HTML editor and this really complicates things ... I have to submit the form before I can reliably read the content of that input.

I am already using jQuery in the page so maybe the answer is there ... I will do a bit more research, I'm guessing I'm gonna be back here asking more questions so I won't close this thread yet.

given that the data is in the fields and the format is known, why submit
preview could be a layer in the current page with the correct css to display the information as it appears in the database
something like

<input type='button' value='Preview' onclick="document.getElementbyID('preview').style='display:block;'">
<!-- and -->
<div id='preview' style='/*out in the css this is just a sample*/ z-index:100; bckground:grey; width:100%; height=100%; top:0; left:0;'>some html to layout the page and populate some data spaces with the value of the input fields<br>
and a button onclick=display:none; </div>

popup windows dont work, too many have them blocked by default, layers in the current window operate without being blocked,

I checked it out .... I could not figure it out Twiss, but thank you all the same ... I get the impression that this would do what I want it to but I don't really understand it .... I am a PHP'er and very new to JavaScript.

And then, if you click the preview button, write a script that puts the contents of you real form into this one and submit it.
Edit: perhaps it's better if you use target="preview", so that if you click preview again, it comes in the same window.

And then, if you click the preview button, write a script that puts the contents of you real form into this one and submit it.
Edit: perhaps it's better if you use target="preview", so that if you click preview again, it comes in the same window.

This is where it all started for me Twiss .... I wrote two forms and filled one with hidden fields which mirrored the fields available to the user.

This form would submit to a pop up and the user facing form would post to the appropriate action page in the main window.

I used onchange to keep the hidden fileds in sync with the user facing ones. That's when I discovered that onchange didn't work for the TinyMce textareas.

A little bit of research on TinyMce and I found function that went in the tinyMCE.init which updated as required just like the onchange script that I had written.

Only thing is, it was very unreliable, sometimes it worked sometimes it didn't and the editor was often very buggy.

Hence the conclusion that I will have to use the same form for preview as well as save and I will have submit it to get a reliable result from those TinyMce textareas (there's up to four on a page).

Ah well ... I'm going to wrap it up for the day. I will give it one more day of trying before I go down the server side processing route.