Text Previewer

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Text Previewer

Post by blacksnday »

Since I assume this is mainly done through javascript.. i am posting here.

Situation:
Trying to make a previewer so before someone submits an article
they can preview before they submit.

Whats currently working:
Everything... except for 2 issues.

1. When the 'preview' button is submitted, the pop-up window displays
but it shows the last preview article in the database. If the
pop-window is refreshed it then shows the correct current preview.
p.s.
I have tried

Code: Select all

header("Cache-Control: no-cache, must-revalidate");
but that hasnt fixed the display issue

2. On my form, I want the preview pop-up to show without the form
going to the action(thanks.php) page. However I cant figure out a way
for the post fields to be recongnized without it first going to my Thanks.php page.
Meaning that it won't insert any data to the db

any suggestions?

btw here is my current code:

Preview Javascript

Code: Select all

<SCRIPT LANGUAGE="JavaScript">
<!--
function bashPreview(form) {
win = window.open('preview.php','','width=400,height=400,left=312,top=184,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0');
}
//-->
</script>
php code to insert preview to db then echo it
out for the preview.php to show it:

Code: Select all

if ($_POST['preview']) { 
   @mysql_query ("INSERT INTO table (row, roww rowww, more, imoree) VALUES ('$user', '$email', '$bash', '$lova', '$ip')");
   echo $newsfunctions->show_last_entry();
   exit;
   }
and the preview button:

Code: Select all

<input name='preview' type='submit' id='preview' value='preview' onClick='bashPreview(this.form)' />
Post Reply