SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Zealot think5577's Avatar
    Join Date
    Sep 2002
    Location
    Richmond, VA
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple Drop Down & pop up window

    Hey everyone,

    Got something for you. I would like to have links from a drop down menu go to a different CENTERED pop-up window. I capped "centered" cause a lot of code out there does not center the pop ups.

    Anyway. I'm having trouble with it cause I think javascript (where Im getting the code from pop-up generators) cant be read in a drop down maybe? Any advice would be great.
    "Truth is a pathless land." - J. Krishnamurti


  2. #2
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    something like...
    Code:
    <form>
    <select name="popper" onchange="window.open(this,'popup','width=400,height=300')">
    <option value="http://www.whatever.com">whatever.com</option>
    ...
    </select>
    </form>
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  3. #3
    SitePoint Zealot think5577's Avatar
    Join Date
    Sep 2002
    Location
    Richmond, VA
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks for the code.

    I plugged it into my code, with the drop downs Im using, but it says,

    "Cant find file." Then it gives me the path "blah/blah/blah/[object SELECT]"

    Here is my code-

    <td width="154" valign="top">
    <select name="popper" onchange="window.open(this,'popup','width=400,height=300')">
    <option selected="selected">001
    <option>text
    <option>text
    <option value="http://www.google.com">link</option></select>
    </td>

    Then I tested the code by itself, it didnt work. I replaced the whatever.com with google.com, but not, I got nothing.

    Since Im writing this, I might as well ask you some stuff about the code.

    1. Can it be centered?
    2. Can I take the address bar out of that code?

    Oh, and my drop downs are not in forms.

    Thanks again.
    "Truth is a pathless land." - J. Krishnamurti


  4. #4
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please repost to the JavaScript board, and you'll get an answer.
    ::: certified wild guess :::

  5. #5
    SitePoint Zealot think5577's Avatar
    Join Date
    Sep 2002
    Location
    Richmond, VA
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Repost what JS board?

    One more thing... just to let everyone know. Im creating this site with the majority of links on drop downs, ie, pop-ups, new window links, and mailto.
    "Truth is a pathless land." - J. Krishnamurti


  6. #6
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by think5577
    Im creating this site with the majority of links on drop downs,
    which is a bad idea not only in terms of accessibility, but also search engine indexability...

    if it's not a proper link, or if there's no way to access pages without javascript, users with text browsers and search engine spiders won't be able to use it
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  7. #7
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use this script, called like so:
    Code:
    <select name="popper" onchange="v=options[selectedIndex].value;if(v)NewWindow(v,'win','width','height','yes')">
    <option value="" selected="selected">001</option>
    <option value="">text</option>
    <option value="">text</option>
    <option value="http://www.google.com">link</option>
    </select>
    Agree with redux; check here for more info.
    ::: certified wild guess :::

  8. #8
    SitePoint Zealot think5577's Avatar
    Join Date
    Sep 2002
    Location
    Richmond, VA
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by redux
    which is a bad idea not only in terms of accessibility, but also search engine indexability...

    if it's not a proper link, or if there's no way to access pages without javascript, users with text browsers and search engine spiders won't be able to use it
    Hey redux,

    Yeah I understand all the issues with drop downs, but this site is kind of an experimental site. But thanks for the concern.

    Hey adios, thanks for the code, Ill try it tonight.
    "Truth is a pathless land." - J. Krishnamurti


  9. #9
    SitePoint Zealot think5577's Avatar
    Join Date
    Sep 2002
    Location
    Richmond, VA
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, well it works, but its still resizeable even after I said 'no'

    heres my code-

    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script language="javascript">

    var win = null;
    function NewWindow(mypage,myname,w,h,scroll){
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings =
    'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
    win = window.open(mypage,myname,settings)
    }

    </script>
    </head>

    <body>
    <select name="popper" onchange="v=options[selectedIndex].value;if(v)NewWindow(v,'win','420','315','no','no')">
    <option value="" selected="selected">001
    <option value="">text
    <option value="">text
    <option value="http://www.google.com">link
    </select>
    <select name="select" onchange="v=options[selectedIndex].value;if(v)NewWindow(v,'win','420','315','no','no')">
    <option value="" selected="selected">002 </option>
    <option value="">text </option>
    <option value="">text </option>
    <option value="http://www.cnn.com">link </option>
    </select>
    </body>
    </html>
    "Truth is a pathless land." - J. Krishnamurti


  10. #10
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well...you said 'no' - but, nobody was listening.

    These arguments:
    Code:
    NewWindow(1: v, 2: 'win', 3: '420', 4: '315', 5: 'no', 6: 'no')">
    ...are passed to NewWindow, and get assigned to the parameter variable in the same position in the parentheses. Notice anything?
    Code:
    function NewWindow(1: mypage, 2: myname, 3: w, 4: h, 5: scroll){
    Six in - five out. Then the line that modifies the settings ignores it. Oops. Just hardcode the 'resizable' argument (notice the spelling).
    Code:
    settings =........LeftPosition+',scrollbars ='+scroll+',resizable=no'
    ::: certified wild guess :::

  11. #11
    SitePoint Zealot think5577's Avatar
    Join Date
    Sep 2002
    Location
    Richmond, VA
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks adios, works great.

    Now one last thing, heres my code-

    <select name="popper" onchange="v=options[selectedIndex].value;if(v)NewWindow(v,'win','420','315','no','no')"style="width: 150px;">
    <option selected="selected">text1</option>
    <option>----------</option>
    <option>text2</option>
    <option>text3</option>
    <option>text4</option>
    <option value="link">click here to view

    </select>

    It works fine when you click the links "option", but if I accidently hit one of the text "options" it tries to open it. And of course, I dont want that. Is there any way I can make those "dead" so nothing happens?

    Thanks again.
    "Truth is a pathless land." - J. Krishnamurti



Bookmarks

Posting Permissions

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