<select> drop down and window.location

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinpkl
    New Member
    • Oct 2008
    • 41

    <select> drop down and window.location

    hi all

    i have two dynamic drop downs of dealer id and category id which work properly with window.location

    Code:
    var dealerid;
    function getList(xyz)
    {
    window.location='manage_products.php?category_id=' + xyz;
    }
    function getProducts(dealer_id)
    {
    var catid=document.form1.category.value;
    window.location='manage_products.php?dealer_id=' + dealer_id + "&category_id="+catid ;
    }
    but now i want to add static drop down of sub category and make use of window.location which i m not able to do

    Code:
    <select name="sub_catg" onchange="getSb(this.value)"  id="sub_catg">
    <option>Select Sub Category</option>
    <option value="Batteries">Batteries</option>
    <option value="Leather & PU Cases">Leather &amp; PU Cases</option>
    <option value="Crystal & Rubber Coated Cases">Crystal &amp; Rubber Coated Cases</option>
    <option value="Car Mounts & USB Cradles">Car Mounts &amp; USB Cradles</option>
    <option value="AC Chargers & Car Chargers">AC Chargers &amp; Car Chargers</option>
    </select>
    This is function that is not working
    Code:
    <script language="javascript">
    var subid=document.form1.sub_catg.value;
    function getSb(subid)
    {
    window.location='manage_products.php?dealer_id=' + dealer_id + "&category_id="+catid + "&sub_catg=" + subid ;
    }
    </script>
    vineet
    Last edited by vinpkl; Jun 17 '09, 12:14 PM. Reason: code
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    See how you set catid in getProducts()? You need to do the same thing for catid and dealer_id in getSb() too.

    Also, there's no need for the subid line - in fact, it would probably result in a error.

    Comment

    Working...