Click to See Complete Forum and Search --> : size and close a pop up window


beachshooz
12-03-2003, 11:55 AM
http://www.harveygarcia.com/net_results/htmltester/story_net_fit.html

At the link above, I have a quiz where if you check any checkbox except "None of the Above" popup window X appears. If you click "none of the above" popup Y appears.

I can't seem to size the popups and I need some code to close the popups.

Thank you to Batfink for helping make this work...now needs some finetuning.

Pittimann
12-03-2003, 12:27 PM
Hi!

You don't pass the values for the window size.
You just made it:
window.open("http://www.harveygarcia.com/net_results/htmltester/" + new_url);
Just put something like that in your function:

var width = "450"; // popup width
var height = "350"; // popup height
LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
windowproperties =
'height='+height+',width='+width+',top='+TopPosition+',left='+LeftPosition;
newwin = window.open("http://www.harveygarcia.com/net_results/htmltester/" + new_url,'', windowproperties);

For closing the window you should specify, by what means and from there you want it to be closed...

Cheers - Pit

olerag
12-03-2003, 12:28 PM
Following assumes a global "childWin" is declared.

Resizing (and other attributes) are added to the third
argument in the "window.open()" function such as...

function openChildWindow() {
var windowAtt = "width=400, height=300, left=50, right=50";
childWin = window.open(URL,"popWin",windowAtt);
}

Do you want to close the "pop-up" from the parent form
via a "button"?? Make the button and add the onClick
event to it...
<input type="button" value="Close Popup" onClick="closeChildWindow()">

To close the "pop" from the parent, the JS function is...
function closeChildWindow() {
childWin.close();
}

One question... what action do you want if both a legitimate
checkbox AND the "None of the Above" are checked???

beachshooz
12-03-2003, 03:14 PM
Thanks to both of you. The Pittiman code worked beautifully on both browsers.

To answer both Pittiman and olerag questions:

I would like to close the box from the popup window.

To olerag:
Originally, when looking for a script, I found many scripts that count how many checkboxes were checked, tell me IF a box was checked, etc. But I could not find one that would give me one of two popup windows depending on WHICH box was checked. (if the first six boxes are checked, give X popup window, if the 7th checkbox is checked, give popup Y). The code I am using was the closest I could find. Since I barely know Javascript, I will keep searching.

Thanks so much!