2012-06-18 259 views
0

網址:http://localhost/back-office/index.php/staff/shopping笨URI段的URL在末尾附加

當我改變我想要的網址應該是這樣的

http://localhost/back-office/index.php/staff/shopping/1 
http://localhost/back-office/index.php/staff/shopping/2 

爲我上​​改變事件寫JavaScript的每onchange事件的類別

function cat() 
{ 
    var x = document.getElementById('cat').value; 
    document.location = "shopping/" + x; 


} 


    <select name="cate" id="cat" onchange="cat()"> 
     <option value="0">Select Cateogry</option> 
     <?php 
     foreach($get_cat as $category) 
     { 
      echo "<option value=$category->categoryid>$category->category</option>";    
     } 
     ?>  
    </select> 

的javscript作品,但URL獲取附加像

http://localhost/back-office/index.php/staff/shopping/shopping/2 

http://localhost/back-office/index.php/staff/shopping/shopping/shopping/shopping/shopping/shopping/1 

在每個籠子下降盒子onchange事件URL被追加像這樣在最後。

我怎麼能解決這個

+0

這是一個JavaScript的問題,而不是具體的笨。你可以編輯你的標籤嗎? –

回答

1

您需要專門編寫你的url..try這

function cat() 
{ 
    var x = document.getElementById('cat').value; 
    url = "http://localhost/back-office/index.php/staff/shopping/" + x; 
    window.location = url; 

} 
+0

感謝它現在適合我。 –

+0

不客氣! – ruelluna