Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: Popup query

  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Popup query

    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){
    closepop();
    win1 = eval("window.open('" + page + "','popup','top=" + top + ",left=" + left + ",width=" + width + ",height=" + height + ",resizable=" + resize + ",scrollbars=" + scroll + "');")
    }
    function closepop(){
    if (win1.closed == false)
    {win1.close();}
    }

    <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>
    </select>

    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.

    Chris
    Last edited by djfenom; 09-24-2003 at 11:43 AM.

  • #2
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    &nbsp;........ another wild guess ........

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    Thanks

    Chris

  • #4
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    djfenom....
    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....
    &nbsp;........ another wild guess ........

  • #5
    New Coder
    Join Date
    Jun 2002
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

    Chris

  • #6
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    &nbsp;........ another wild guess ........

  • #7
    New Coder
    Join Date
    Jun 2002
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)".....>

    Then:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    <head>
    <title>untitled</title>
    <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;
    			break;
    	}
    }
    
    onload = setSelectByValue;
    
    </script>
    </head>
    <body>
    <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>
    </select>
    </form>
    </body>
    </html>
    The pop-up code:
    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+',
    left='+((chasm-wd-10)*.5)+',top='+((mount-ht-25)*.5)+',scrollbars,status,titlebar');
         if (putItThere & !putItThere.closed)     
             putItThere.focus();
         return false;
    }
    You'll need to remove the spaces before 'open' and the linefeeds after ,height='+ht+', inserted by this editor.
    Last edited by cheesebag; 09-24-2003 at 05:22 PM.
    &nbsp;........ another wild guess ........

  • #9
    New Coder
    Join Date
    Jun 2002
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you so much, this is perfect.

    Cheers.

    Chris


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •