473,372 Members | 1,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

PopUp Causes Form Select Objects to Lose Choices

Hi,
I have a series of Select menus on a page. I am trying to allow the user to
click on the Select title and have it popup a help window. This works fine
with the following code except that all the Select choices are lost.

<A
HREF="javascript:location='menu.jsp';window.open(' menuhelp.jsp?menuID=5','me
nuhelp',)">MenuTitle</A>

I saw an example of a popup on a website that did not lose the menu choices.
This code never calls the javascript function and I can't figure out why. I
know it does not reach the function because it never prints the
out.println("popUp("+page+")");

<A HREF="javascript:popUp('menuhelp.jsp?menuID=5', event)">MenuTitle</A>

function popUp(page,evt){
out.println("popUp("+page+")");
win2 = window.open(page,'pop',"width=400,height=300");
opened = true;
win2.focus();
}

My goal is to get a popup that does not lose my menu choices. Any help is
greatly appreciated.
Thanks,
Mica Cooper

PS. My environment for testing is IE 6.0.2800 with Resin 2.0.3 for my JSP
container on Windows 2000.
Jul 20 '05 #1
6 2971
Lee
Mica said:

Hi,
I have a series of Select menus on a page. I am trying to allow the user to
click on the Select title and have it popup a help window. This works fine
with the following code except that all the Select choices are lost.

<A
HREF="javascript:location='menu.jsp';window.open( 'menuhelp.jsp?menuID=5','me
nuhelp',)">MenuTitle</A>
Don't abuse the javascript: pseudo-protocol like that.
Despite the number of examples you'll find, it's poor practice.
Setting the location attribute is causing your page to reload.

<a href="youShouldEnableJavaScript.html"
onclick="window.open('menuhelp.jsp?menuID=5','menu help');return false">

This code never calls the javascript function and I can't figure out why. I
know it does not reach the function because it never prints the
out.println("popUp("+page+")"); function popUp(page,evt){
out.println("popUp("+page+")");


is out.println() defined as a method in your envirnment?
That's not a standard JavaScript method (JavaScript != Java).

Jul 20 '05 #2
Lee,
Thanks a bunch! I am a server-side Java guy :) You pegged me. What with the
economy and all, the company has got the bright idea that we are experts
with Javascript to. I'll never forget trying to explain the difference to a
director of hiring at a fortune 500.

Your code works...and now I understand why the page was always reloading. I
was wanting to kill the popup when the form unloads. That is why I was
trying a popUp function (and a popDown). Any ideas why it doesn't work? It
does not do a popup at all but redirects to the menuhelp page.

Thanks,
Mica

<A HREF="menuhelp.jsp?menuID=5"
onclick="popUp('menuhelp.jsp?menuID=5',event);retu rn false">
MenuTitle
</A>

function popUp(page,evt){
document.write("inside popUp("+page+")");
xCor=(document.layers)?(screen.width/2):(screen.width/2);
ypos=50;
topPos=ypos;
leftPos=xCor - 300;
details = "width=496,height=305,scrollbars=yes,resizable,lef t=" +
leftPos + ",top=" + topPos;
win2 = window.open(page,'pop',details);
opened = true;
win2.focus();
}
Jul 20 '05 #3
"Mica Cooper" <mi**@aisus.com> writes:
I'll never forget trying to explain the difference to a director of
hiring at a fortune 500.
"You *point* stoopid! Me *bang chest* smart! Here, banana!"
Maybe my negotiation skills need polishing :)
Your code works...and now I understand why the page was always reloading. I
was wanting to kill the popup when the form unloads. That is why I was
trying a popUp function (and a popDown). Any ideas why it doesn't work? It
does not do a popup at all but redirects to the menuhelp page.
The symptoms suggests an error in the Javascript.

If the error is syntactical, the function is never defined (it barfs
during parsing), and it fails when trying to call the non-existing
function. The error need not be in the function itself, it can be anywhere
in the same script element.

If the error is in the function, execution fails during the call to
the function.

In both cases, we never reach "return false", so the href link is
followed.
<A HREF="menuhelp.jsp?menuID=5"
onclick="popUp('menuhelp.jsp?menuID=5',event);retu rn false">
MenuTitle
</A>
I assume some <script type="text/javascript> wrappings around the code
here :)
function popUp(page,evt){
document.write("inside popUp("+page+")");
"document.write" is bad. Unless the document is "open", as while it is
being parsed, writing to it erases the current page.
xCor=(document.layers)?(screen.width/2):(screen.width/2);
var xCor = screen.width/2;

Document.layers is not a foolproof way to recognize Netscape 4.

In general, use local variables (declared with "var") unless you need
the variables to be global. In that case, declare them with "var" outside
the function.
ypos=50;
topPos=ypos;
leftPos=xCor - 300;
Is leftpos perhaps negative after this (probably not, that would
require the screen width to be less than 600, but on very small
screens, it can happen).
details = "width=496,height=305,scrollbars=yes,resizable,lef t=" +
leftPos + ",top=" + topPos;
win2 = window.open(page,'pop',details);
opened = true;
win2.focus();
It should have focus already, but its not an error to be extra certain.
}


I can't see any obvious errors. Maybe it is somewhere in the
surrounding Javascript. Try running the page in Mozilla or Opera and
see if they give an error in the Javascript error console, that might
tell you what the problem is.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
"Mica Cooper" <mi**@aisus.com> wrote in message
news:14******************************@free.teranew s.com...
<snip>
... I am a server-side Java guy :) ... <snip>

Which means that you should be familiar with the logic of this
statement:-
xCor=(document.layers)?(screen.width/2):(screen.width/2);

<snip>

- as it has a direct parallel in Java.

You should be applying the same standards to your JavaScript authoring
as to your Java code. Which means reading and understanding what you
write.

You have also written a function that creates 7 global variables when at
lest 5 of them could be local. You wouldn't give variables more scope
than then need in Java so why do so with JavaScript. The scope
resolution rules may differ but that is no reason for ignoring the
principal.

Richard.
Jul 20 '05 #5
DU
Mica Cooper wrote:
Hi,
I have a series of Select menus on a page. I am trying to allow the user to
click on the Select title and have it popup a help window. This works fine
with the following code except that all the Select choices are lost.

<A
HREF="javascript:location='menu.jsp';window.open(' menuhelp.jsp?menuID=5','me
nuhelp',)">MenuTitle</A>

There should not be any comma at the end of that window.open() call:
either you have a 3rd argument or you don't.
As others mentioned, "javascript:" pseudo-protocol is bad for multiple
reasons and is to be avoided in href values.
I saw an example of a popup on a website that did not lose the menu choices.
This code never calls the javascript function and I can't figure out why. I
know it does not reach the function because it never prints the
out.println("popUp("+page+")");

<A HREF="javascript:popUp('menuhelp.jsp?menuID=5', event)">MenuTitle</A>

function popUp(page,evt){
out.println("popUp("+page+")");
win2 = window.open(page,'pop',"width=400,height=300");
opened = true;
win2.focus();
}

What is the event argument (evt parameter) for in there? If you're
coding for MSIE only, then the window.event object is always accessible,
referencable anyway. If you coding for W3C web standards compliant and
DOM 2 Event compliant browsers, then again, this is not the way to code
a function. In any case, the event argument (evt parameter) serves no
purpose at all in there.
opened = true;
win2.focus();
opened and the focus() call serve no purpose really.

My goal is to get a popup that does not lose my menu choices. Any help is
greatly appreciated.
Thanks,
Mica Cooper

PS. My environment for testing is IE 6.0.2800 with Resin 2.0.3 for my JSP
container on Windows 2000.


DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #6
Thank you!
Error found. This has shown me that my JS Visual Quickstart Guide is
severely lacking. I have the JavaScript Bible and another JS book on order.
I resolve that if I must do JS I'll do it right! :) Now I that I realize JS
has so much power, I'll start migrating server side presentation logic to JS
where appropiate.
Mica

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:is**********@hotpop.com...
"Mica Cooper" <mi**@aisus.com> writes:
I'll never forget trying to explain the difference to a director of
hiring at a fortune 500.


"You *point* stoopid! Me *bang chest* smart! Here, banana!"
Maybe my negotiation skills need polishing :)
Your code works...and now I understand why the page was always reloading. I was wanting to kill the popup when the form unloads. That is why I was
trying a popUp function (and a popDown). Any ideas why it doesn't work? It does not do a popup at all but redirects to the menuhelp page.


The symptoms suggests an error in the Javascript.

If the error is syntactical, the function is never defined (it barfs
during parsing), and it fails when trying to call the non-existing
function. The error need not be in the function itself, it can be anywhere
in the same script element.

If the error is in the function, execution fails during the call to
the function.

In both cases, we never reach "return false", so the href link is
followed.
<A HREF="menuhelp.jsp?menuID=5"
onclick="popUp('menuhelp.jsp?menuID=5',event);retu rn false">
MenuTitle
</A>


I assume some <script type="text/javascript> wrappings around the code
here :)
function popUp(page,evt){
document.write("inside popUp("+page+")");


"document.write" is bad. Unless the document is "open", as while it is
being parsed, writing to it erases the current page.
xCor=(document.layers)?(screen.width/2):(screen.width/2);


var xCor = screen.width/2;

Document.layers is not a foolproof way to recognize Netscape 4.

In general, use local variables (declared with "var") unless you need
the variables to be global. In that case, declare them with "var" outside
the function.
ypos=50;
topPos=ypos;
leftPos=xCor - 300;


Is leftpos perhaps negative after this (probably not, that would
require the screen width to be less than 600, but on very small
screens, it can happen).
details = "width=496,height=305,scrollbars=yes,resizable,lef t=" +
leftPos + ",top=" + topPos;
win2 = window.open(page,'pop',details);
opened = true;
win2.focus();


It should have focus already, but its not an error to be extra certain.
}


I can't see any obvious errors. Maybe it is somewhere in the
surrounding Javascript. Try running the page in Mozilla or Opera and
see if they give an error in the Javascript error console, that might
tell you what the problem is.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: TG | last post by:
I have a form that POSTs to itself and validates data entered into the form. If all is well the form performs a header location command to move to the next input form in the series. If the user has...
1
by: Alan | last post by:
I am trying to use javascript modal popup windows (window.createModalWindow) to display HTML forms. The problem is - the form size and content varies. The same entry form, under different...
4
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a...
0
by: Tim Wallace | last post by:
I am new to the .Net world, and have been unable to find a good source on the Web to help me figure this one out, so here goes... I have an ASPX page on which exists a DataGrid. I need to allow...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
1
by: Matt Jensen | last post by:
Howdy I've got a ASP.NET webform page that pops up a window for a user to make a selection. Once they make a selection in this popup window, the form in the popup is submitted an update to the...
2
by: Kiyomi | last post by:
Hello, I have some codes under event ButtonSend_Click to check the user input values. This check is complicated enough using different stored procedures. Then according the result of the...
8
by: JJ | last post by:
Whats the best way to pass a variable from a popup to the current page (without a postback on the current page). I have a form on 'page1' with various text input boxes. One box contains an image...
4
by: amerar | last post by:
Hi Everyone, I am very new to this, so I'm hoping someone can help. I have a form with buttons that a user can click. What I need to do is that when a user clicks a button, before the form...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.