Welcome Guest Search | Active Topics | Members

Popup - Onclick javascipt code. Help! Options
rogem002
Posted: Sunday, August 20, 2006 12:03:49 AM

Rank: Martian Estate Agent

Joined: 9/14/2003
Posts: 3,358
Location: United Kingdom
I'm having a little problem getting PHP and Javascript to work together on a little project i'm working on. Here's my problem,

I have a form that has to be sent to one file and it contains the fields i want to appear on a preview popup.
I did use a script (Below) that wrote a tempary file, but it did not work for me as it could not load a template into the file.

Can only help?

The Javascript i was using that wrote tempary files looks like this

<script language="JavaScript">

function preview() { 

temp = document.reply.message.value; 

preWindow = open("", 

"preWindow"," menubar=yes, scrollbars=yes"); 

preWindow.document.open(); 

preWindow.document.write(temp); 

preWindow.document.close(); 
}; 

</script>

Then i done a onclick (Form Button) to send it to preview().

What i really need is a javascript that will either set a cookie or see what is in the field and post it to another page.

Full On Design
rogem002
Posted: Sunday, August 20, 2006 9:21:25 PM

Rank: Martian Estate Agent

Joined: 9/14/2003
Posts: 3,358
Location: United Kingdom
If it helps i want somthing a little like swoj.com's preview button.

Full On Design
Steviepunk
Posted: Monday, August 21, 2006 12:24:19 AM

Rank: Admin

Joined: 8/26/2002
Posts: 3,467
Location: United Kingdom
Rather than do a POST, the forum cheats a little, it sets the content of the message textarea into a cookie and then loads the pop-up page it wants. The pop-up page then reads the preview text from the cookie.

The javascript that does this is as folows (in this case, for the pop-up spell checker)

function OpenSpellCheck()
{
var curCookie = "strMessagePreview=" + escape(document.PostTopic.Message.value);
document.cookie = curCookie;
popupWin = window.open('pop_spellcheck.asp', 'preview_page', 'scrollbars=yes,width=650,height=400')
}

If your code is not working, check that you have your form named correctly, the format of the value object you are trying to reference is document.FORMNAME.FORMOBJECT.value, so make sure your form has the id 'reply' (based on your code), failing that change the form name and reference to something else to make sure that reply is not a keyword (ie. for the HTTP Reply)

If your form only has one submit button, you could try opening the window and using the TARGET parameter for the form to send the form to the pop-up window, though this would apply to all submit buttons on the form (if you can make it work with the TARGET parameter, I forget if that is possible.)
rogem002
Posted: Tuesday, August 22, 2006 1:03:37 AM

Rank: Martian Estate Agent

Joined: 9/14/2003
Posts: 3,358
Location: United Kingdom
Would i need Javascript to retrive the cookie? I know how to do it with php...but when i tired it did not work amazingly.

Full On Design
Steviepunk
Posted: Tuesday, August 22, 2006 6:53:39 PM

Rank: Admin

Joined: 8/26/2002
Posts: 3,467
Location: United Kingdom
I don't think you would need to retreive the cookie with javascript, PHP should be able to reference the cookies in it's own code (they are sent with each page request). I gues the question would be whether the cookie is set before the pop-up window is opened, so make sure you set your cookie before that.
rogem002
Posted: Thursday, September 07, 2006 7:59:35 PM

Rank: Martian Estate Agent

Joined: 9/14/2003
Posts: 3,358
Location: United Kingdom
I just came up with

					  <script language="JavaScript" type="text/javascript">
function OpenPreview()
{
var curCookie = "strTextNewPage=" + escape(document.NewPage.text.value);
document.cookie = curCookie;
popupWin = window.open('admin.php?p=pop_preview', 'preview_page', 'scrollbars=yes,width=650,height=400')
}
</script>
					  <input class="button" name="Preview" value=" Preview " type="button" onclick="OpenPreview()" />


Something is wrong with that, but i'm not sure what :( I can't seem to get the thing to make a cookie.

Full On Design
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.