2016-06-28 72 views
0

我想將類別鏈接到他們自己的頁面。所以我的意思是,當我點擊「酒店」應該打開的頁面是分類/酒店如何鏈接類別<option>標籤

enter image description here

這是當前代碼

<select name="category"> 
    <option value="">Any Category</option> 
    <option value="clubs">Clubs</option></a> 
    <option value="hotels">Hotels</option> 
    <option value="pubbar">Pub&amp;Bar</option> 
    <option value="restaurants">Restaurants</option> 
</select> 

可以說,我想這樣的

鏈接
<option value="www.website.com/event_cat/clubs/> Clubs </option> 
    <option value="www.website.com/event_cat/hotels/> Hotels </option> 
.. and so on 

但是當我做,它引導到這個頁面:

www.website.com/events/?time=&category=%2Fevent_cat%2Fclubs%2F&location= 

回答

1

JSfiddle Demo

<html> 
    <body> 
     <form name="blah_blah"> 
     <select name="ddmenu_name" id="ddmenu_name" style="width: 80% !important;"> 
      <option value="" selected>Select Site</option> 
      <option value="http://www.yahoo.com">Yahoo!!!</option> 
      <option value="http://www.gmail.com">Gmail</option> 
      <option value="http://www.google.co.in">Google</option> 
      <option value="http://www.facebook.com">Facebook</option> 
     </select> 
     <input type="button" name="Submit" value="Go!" onClick="window.open(ddmenu_name.value,'newtab'+ddmenu_name.value)"> 
     </form> 
    </body> 
</html> 
+0

感謝它的工作,但我怎樣才能打開鏈接在同一個標​​籤?

0

既然你已經選擇了,在第一個選項的第一個選項,保留此值爲空,並添加平變化,如下面的代碼:

<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);"> 
    <option value="">Any Category</option> 
    <option value="www.website.com/event_cat/clubs/">Clubs</option> 
    <option value="www.website.com/event_cat/hotels/">Hotels</option> 
    <option value="pubbar">Pub&amp;Bar</option> 
    <option value="restaurants">Restaurants</option> 
</select> 
1

你只必須使用完整域名路徑與http或https(如果其安全服務器)

<option value="http://www.website.com/event_cat/clubs/> Clubs </option> 
<option value="http://www.website.com/event_cat/hotels/> Hotels </option>