codeigniter uri segment url appending at the end

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

when i change the category on every onchange event i want the url should be like this

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

for that i wrote javascript on change event

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> 

the javscript works , but the url getting appended like

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

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

on every cagetory drop box onchange event the url is getting appended like this at the end.

how could i solve this

Answers


you need to specifically code your url..try this

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

}

Need Your Help

Order by, group by, first result in HQL (convert from Oracle SQL)

java oracle hibernate hql sql-order-by

How would represent the following Oracle SQL in Hibernate HQL.