onchange redirect

Posted on 2006-05-17
Last Modified: 2008-01-09
I have a <select id=aid >
</select> element in my abs.aspx page.

I want to redirect the user onchange of selectbox to the same page and pass a parameter cid which will be the selected value.

i.e if user selects UK it should redirect to abs.aspx?cid=2

Pls help

Question by:sureshraina
    LVL 6

    Expert Comment

    The following Javascript implementation should work (NOTE: you have a syntax error on your option tags, which is corrected below):

                function cboChange(obj)
                      window.location.href = '' + obj.options[obj.selectedIndex].value;

    <select id="aid" onchange="cboChange(this);" >
          <option value="1">US</option>
          <option value="2">UK</option>

    Author Comment


    But this is opening in a new window. I want in the same window..

    thanks again
    LVL 6

    Expert Comment

    ok, change the line with window.location.href to:

                      parent.window.location.href = '' + obj.options[obj.selectedIndex].value;

    Author Comment

    It is still opening in new window after changing.

    I cannot submit the form as i am doing other things on submit
    LVL 26

    Accepted Solution

    remember u are using ASP.Net and no more coding in ASP .. so try to use its inbuild functionalities wherever possible. ...

    so use a web control and instead of a HTML control ..
    i.e. a "dropdownlist" control instead of the HTML "select" tag ..
    set the "Autopostback" property of the "dropdownlist" to "true" ...

    then in the "selectedindexchanged" event of the dropdownlist ..
    write the code

    response.redirect "abs.aspx?cid=" & dropdownlist1.selectedValue

    LVL 2

    Expert Comment

    This might work as well.  Replace 'ddlName' with the name of your Drop Down List control.

    Response.Write("<script>" & ddlName.SelectedValue &  "');</script>")
    LVL 26

    Expert Comment

    just curious, any particular reason for a grade B?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now