View Full Version : Popup query

09-24-2003, 11:45 AM
I'm using the following code to create a popup window which has a form located inside it:

var win1 = new Object;
function pop(page,top,left,width,height,resize,scroll,fullscreen){
win1 = eval("window.open('" + page + "','popup','top=" + top + ",left=" + left + ",width=" + width + ",height=" + height + ",resizable=" + resize + ",scrollbars=" + scroll + "');")
function closepop(){
if (win1.closed == false)

<a href="javascript: pop('location-form.html','15','15','400','400','no','yes');">

To get to the form you click on a region on a map. What I need is for each region on the map, I need the dropdown select field to be selected on the region that was clicked on.

<select name="select">
<option value="Yorkshire" selected>Yorkshire</option>
<option value="Cheshire">Cheshire</option>
<option value="Lincolnshire">Lincolnshire</option>
<option value="Durham">Durham</option>
<option value="Shropshire">Shropshire</option>

For example, if a person clicked on Cheshire, then the popup form would appear and under the dropdown menu, Cheshire would be selected.

Hope somebody can help.

Thanks in advance.


09-24-2003, 05:20 PM
Omitted some key details. Is there a different form for each region on the map? If so, how is that data being passed to the server?

This is more easily done server-side, particularly if you're running script there anyway, but it could be handled at the browser by passing the region as querystring data, and setting the select onload.

That is the worst pop-up opener ever. :eek:

09-24-2003, 05:24 PM
There is only one form for each region on the map.

I was thinking more of an onload, but don't know how to implement it.

Hope you can help, you can change the popup code if you like. :)



09-24-2003, 05:27 PM
ME: Is there a different form for each region on the map?
YOU: There is only one form for each region on the map.I think you missed my point....;)

09-24-2003, 05:29 PM
Ok, there is only one form, you click on any region on the map and you get the same form, rather than do 20 forms with the dropdown menu selection different, I thought this could be achieved in javascript.

Thanks again


09-24-2003, 05:40 PM
You've mentioned 'map' several times. Are we talking 'image map'?

Think about it: for a program to 'know' which region has been clicked on, there has to be some mechanism for determining where the clickpoint was. Setting the drop-down is the easy part.

Might want to look into client-side image maps. Are you using a graphics program?

09-24-2003, 05:43 PM
I am using a geographical map of the UK, which is split up into regions using an imagemap, each region can be clicked to open the popup form.

09-24-2003, 06:11 PM
Hoped you might be set up that way. :)

Try this: add a querystring to each link in the map, consisting of

1) question mark
2) 'region='
3) name of region

So.....<area href="location-form.html?region=Yorkshire" target="putItThere" onclick="return deadCenter(this.href)".....>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"

<script type="text/javascript" language="javascript">

function setSelectByValue()
var Qstr = unescape(location.search.substring(1));
var region = Qstr.split('region=')[1];
var opt, i = 0, oSelect = document.form_name.region;
while (opt = oSelect.options[i++])
if (opt.value == region)
opt.selected = true;

onload = setSelectByValue;

<form name="form_name">
<select name="region">
<option value="Yorkshire" selected="selected">Yorkshire</option>
<option value="Cheshire">Cheshire</option>
<option value="Lincolnshire">Lincolnshire</option>
<option value="Durham">Durham</option>
<option value="Shropshire">Shropshire</option>

The pop-up code:

var putItThere = null;
var chasm = screen.availWidth;
var mount = screen.availHeight;
var wd = chasm*.9; // percentage of screen width occupied by pop-up
var ht = mount*.8; // percentage of screen height occupied by pop-up

function deadCenter(url) {
putItThere = window. open(url,'putItThere','width='+wd+',height='+ht+',
if (putItThere & !putItThere.closed)
return false;

You'll need to remove the spaces before 'open' and the linefeeds after ,height='+ht+', inserted by this editor.

09-25-2003, 10:02 AM
Thank you so much, this is perfect.