Create a preview button on a form?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
waradmin
Forum Contributor
Posts: 240
Joined: Fri Nov 04, 2005 2:57 pm

Create a preview button on a form?

Post by waradmin »

I want a popup to appear showing a preview of the data so the user can see how it will be formatted when posted. Then they can just close that window and hit post to actualy send it to the DB, however I cant figure it out for the life of me.

I basicly want to pass the $_POST value for the textarea into a new window so I can echo it onto the popup window, without actualy sending the page to the DB using the submit button.

Current form code:

Code: Select all

<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<center><p><input type="hidden" name="action" value="sign" />
<textarea cols="60" rows="5" name="onwall" style="font-size: 12px; font-family: Georgia;" onKeyDown="limitText(this.form.onwall,this.form.countdown,255);" 
onKeyUp="limitText(this.form.onwall,this.form.countdown,255);"></textarea></p>
<p><font size="1">(Maximum characters: 255)<br>You have <input readonly type="text" name="countdown" size="3" value="255" style="background-color: #d8dfea; color: #000000; border-top: 1px solid #d8dfea; border-left: 1px solid #d8dfea; border-right: 1px solid #d8dfea; border-bottom: 1px solid #d8dfea;"> characters left.</font></p>
<input type="submit" name="submit" value="Post" style="color: #FFFFFF; background-color: #3b5998;"></center>
</form>
I googled the heck out of this, found nothing useful.

Thanks
-Steve
danharibo
Forum Commoner
Posts: 76
Joined: Thu Aug 17, 2006 8:56 am

Post by danharibo »

use a Java PoPuP ? to hide URL and use php to send the FOrm values to PHP_SELF with ?Preview=1 to show the preview (Use $_GET )
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Use a button form element with an event handler of onClick to force the form to submit to a new window which handles the form processing.
User avatar
waradmin
Forum Contributor
Posts: 240
Joined: Fri Nov 04, 2005 2:57 pm

Post by waradmin »

I have tried a few idea's that I found on google concerning onClick events, etc yet none have worked. Can anyone point me in a direction with some helpful information, after atleast 3 hours on this I am still coming up blank.

Thanks in advance.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Why don't you just implement a preview function similar to the thread-post preview on these boards?
Post Reply