Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Need some JavaScript Help (Popups)

Need some JavaScript Help (Popups)
Thread Tools
Senior User
Join Date: Mar 2001
Location: Crystal, MN
Status: Offline
Reply With Quote
Jun 3, 2002, 01:52 PM
 
OK. Here is what I am trying to do. I want to use some popup windows in a good way. I am using them for page help items and the such.

Here is the code I have been using and this first part works great:

</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
At the top of the page:
&lt;SCRIPT TYPE=&quot;text/javascript&quot;&gt;
&lt;!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
return false;
}
//--&gt;
&lt;/SCRIPT&gt; </pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Then my links are the following:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> &lt;A HREF=&quot;popupbasic.html&quot; onClick=&quot;return popu (this, 'notes')&quot;&gt;my popup&lt;/A&gt; </pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Easy...no problem. This works like a champ. However, I want to do is the following. I am doing a search on the page and I want the popup to have the search results in it. Here is the code of the page...sorry, but it is kinda long:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">&lt;?php
require(&quot;config/configdb.php&quot;
$installBase = ereg_replace(&quot;(^.*)[/\\]$&quot;, &quot;\\1&quot;, $config[&quot;installBase&quot;]);
?&gt;

&lt;SCRIPT TYPE=&quot;text/javascript&quot;&gt;
&lt;!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
return false;
}
//--&gt;
&lt;/SCRIPT&gt;
&lt;TABLE WIDTH=&quot;100%&quot; CELLSPACING=&quot;0&quot; CELLPADDING=&quot;0&quot; BORDER=&quot;0&quot;&gt;
&lt;TR&gt;
&lt;TD ALIGN=&quot;center&quot;&gt;
&lt;FORM METHOD=&quot;get&quot; ACTION=&quot;searchpics.php&quot; TARGET=&quot;_self&quot;&gt;
&lt;TABLE CELLSPACING=&quot;0&quot; CELLPADDING=&quot;0&quot; BORDER=&quot;0&quot;&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;INPUT TYPE=&quot;text&quot; NAME=&quot;q&quot; SIZE=&quot;25&quot; TABINDEX=&quot;1&quot;&gt;&amp;nbs p;&lt;/TD&gt;
&lt;TD&gt;&lt;INPUT TYPE=&quot;submit&quot; VALUE=&quot;Search&quot; TABINDEX=&quot;3&quot;&gt;&amp;nbs p;&lt;/TD&gt;
&lt;TD&gt;
&lt;SELECT NAME=&quot;r&quot; TABINDEX=&quot;2&quot;&gt;
&lt;OPTION VALUE=&quot;0&quot;&gt;All results&lt;/OPTION&gt;
&lt;OPTION VALUE=&quot;5&quot;&gt;5 results&lt;/OPTION&gt;
&lt;OPTION SELECTED VALUE=&quot;10&quot;&gt;10 results&lt;/OPTION&gt;
&lt;OPTION VALUE=&quot;20&quot;&gt;20 results&lt;/OPTION&gt;
&lt;OPTION VALUE=&quot;30&quot;&gt;30 results&lt;/OPTION&gt;
&lt;OPTION VALUE=&quot;50&quot;&gt;50 results&lt;/OPTION&gt;
&lt;/SELECT&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;/TD&gt;
&lt;TD COLSPAN=&quot;2&quot;&gt;&amp;nbsp ;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TABLE&gt;
&lt;/FORM&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TABLE&gt;</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I know nothing of JavaScript. Know PHP really well, but not much for JavaScript. What I tried doing is adding the onClick inside both the form and input tags.

Adding the onClick to the form tag makes the popup window launch when you click inside the search box (funny - but not what I was looking for). The onClick inside the input does nothing.

Any help would be great, and again sorry for the long a$$ post, but I figure being able to see the code is easier for everyone.

You can see the page I am working on at. When I do a search on that page, I want it to display the results in a popup window, not a new page.

<a href="http://baby.brynteson.info/pics.php" target="_blank">http://baby.brynteson.info/pics.php</a>

Thanks,

dw9

<small>[ 06-03-2002, 02:53 PM: Message edited by: dawho9 ]</small>
- Intel iMac 20' Core Duo - 1GB RAM
- Technology Blog) http://portalxp.org/Web/blogs/rbrynteson/
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Santa Fe
Status: Offline
Reply With Quote
Jun 3, 2002, 06:04 PM
 
Have the form submit to itself (make the action so it displays the current page's URL). Have some script at the top of each page to see whether the request method is "POST." If it is, write an "onload" JavaScript command in the body tag and pass the page the form results. The pop-up window page can calculate the search results using what it's passed.

I hope this helps. I'm just coming up with a solution off the top of my head.
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Jun 3, 2002, 07:03 PM
 
You're after the 'onsubmit' event - place it in the FORM tag and it should work OK! ( e.g. [FORM METHOD="get" ACTION="searchpics.php" TARGET="_self" ONSUBMIT="yourFunction()"] )

Usually the onsubmit event is used to check forms, validate user entry and stuff like that.
Computer thez nohhh...
     
Fresh-Faced Recruit
Join Date: Jul 2000
Location: Raleigh, NC USA
Status: Offline
Reply With Quote
Jun 5, 2002, 04:03 PM
 
dw9,

I am trying to accomplish the same thing. Have you had any luck?

I can get the popup window functionailty to work, but it's not passing my php variables - so I get empty windows.

Post if you have any luck. I'll do the same.

-spiggott
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:06 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2