Results 1 to 7 of 7

 

Thread: Opening a new window from an option tag

  1. #1
    Dazza30's Avatar
    Registered User

    Status
    Offline
    Join Date
    Mar 2006
    Location
    cheshire uk
    Posts
    1,161
    Thanks
    83
    Thanked 43 Times in 33 Posts


    Please can some one please help?

    I have a bog standard drop down menu on my index page, i need to be able to open the links in it in a new window.

    I cant use target="_blank" because the option tag doesnt support it, is there another way to do it?

  2. #2
    Registered User

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Gillingham
    Posts
    510
    Thanks
    0
    Thanked 4 Times in 1 Post
    You could use the form tag which does allow the target attribute.
    HTML Code:
    <form method="post" name="myform" action="newpage.php" target="_blank">
    <select name="dropdown" onchange="myform.submit()">
    <option>1</option>
    <option>2</option>
    </select>
    </form>
    They came for my 404 and I said nothing

  3. #3
    Dazza30's Avatar
    Registered User

    Status
    Offline
    Join Date
    Mar 2006
    Location
    cheshire uk
    Posts
    1,161
    Thanks
    83
    Thanked 43 Times in 33 Posts
    Quote Originally Posted by Donk View Post
    You could use the form tag which does allow the target attribute.
    HTML Code:
    <form method="post" name="myform" action="newpage.php" target="_blank">
    <select name="dropdown" onchange="myform.submit()">
    <option>1</option>
    <option>2</option>
    </select>
    </form>
    I dont currently use php so how does the newpage.php work?

  4. #4
    Registered User

    Status
    Offline
    Join Date
    Jun 2006
    Posts
    628
    Thanks
    7
    Thanked 70 Times in 67 Posts
    Hi,
    something like this
    <select onchange="window.open(this.options[this.options.selectedIndex].value);">
    <option value="http://google.com">Google</option>
    <option value="http://msn.com">MSN</option>
    </select>


    Cheers,
    Jon

  5. #5
    Registered User

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Gillingham
    Posts
    510
    Thanks
    0
    Thanked 4 Times in 1 Post
    If your not using PHP I would stick with jonsp's solution but for the record the php code newpage.php could look something like this:


    PHP Code:
    Your html head and start of your page
    <?php
    if ($_POST['dropdown']==1){
    ?>
    your html for option 1
    <?
    }
    else if  (
    $_POST['dropdown']==2){
    ?>
    your html for option 2
    <?php ?>
    more html
    They came for my 404 and I said nothing

  6. #6
    Dazza30's Avatar
    Registered User

    Status
    Offline
    Join Date
    Mar 2006
    Location
    cheshire uk
    Posts
    1,161
    Thanks
    83
    Thanked 43 Times in 33 Posts
    Thanks for the input Donk, im going to read a book next week called teach yourself php in 24 hours hopefully it will be of some use.

  7. #7
    Dazza30's Avatar
    Registered User

    Status
    Offline
    Join Date
    Mar 2006
    Location
    cheshire uk
    Posts
    1,161
    Thanks
    83
    Thanked 43 Times in 33 Posts
    Quote Originally Posted by jonsp View Post
    Hi,
    something like this
    <select onchange="window.open(this.options[this.options.selectedIndex].value);">
    <option value="http://google.com">Google</option>
    <option value="http://msn.com">MSN</option>
    </select>


    Cheers,
    Jon
    Thanks a lot jonsp, hopefully this is the answer.



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Masking url and opening in a new window
    By rammy786 in forum Affiliate Marketing Lounge
    Replies: 3
    Last Post: 04-11-07, 11:10 PM
  2. Site is blank page in Internet Explorer
    By warren_p in forum Affiliate Marketing Lounge
    Replies: 12
    Last Post: 28-06-07, 11:10 AM
  3. Opening a sign up window
    By Greedo in forum Programming
    Replies: 2
    Last Post: 22-03-06, 12:54 PM

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
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2