Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 237139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:24:05+00:00 2026-05-11T20:24:05+00:00

I have a real simple problem, but can’t seem to figure it out. The

  • 0

I have a real simple problem, but can’t seem to figure it out.

The following doesn’t work because of the way MVC builds the URL (It includes all the route information). I want pathname to return the virtual directory path only.

All I’m doing is redirecting to a different route when a user selects an ID from a drop down list.

$(document).ready(function() {
    $('#TransactionIds').change(function() {
        document.location = window.location.pathname + "/CeuTransaction/Index/" + $('#TransactionIds').val();
    });
});
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:24:05+00:00Added an answer on May 11, 2026 at 8:24 pm

    Use the UrlHelper to build the path. It will take into account the location of the application relative to the web server root.

    $(document).ready(function() {
       $('#TransactionIds').change(function() {
           document.location = '<%= Url.Action( "Index", "CeuTransaction" ) %>'
                                + '/'
                                + $('#TransactionIds').val();
       });
    });
    

    Alternative: split into two parts so that the function can be included in a javascript library (still needs to be invoked from view or master). With a little bit of work you could make it a jQuery extension, too.

    function redirectOnChange( selector, action )
    {
       $(selector).change( function() {
           document.location = action + '/' + $(selector).val();
       });
    }
    

    In the view:

    $(function() {
        redirectOnChange('#TransactionIds',
                         '<%= Url.Action( "Index", "CeuTransaction" ) %>' );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem itself is simple, but I can't figure out a solution that does
OK, so this should be simple... But I still can't figure it out. I
I have a simple, real life problem I want to solve using an OO
HI I have the following (apparently simple) problem: I have to install a simple
I've run into this problem before and couldn't figure it out, but it's basically
I'm new to jQuery so this may be a real simple answer. I have
I have learned Perl and PHP.So I want to do simple real time project
I'm writing a simple real-estate listing app in Django. Each property needs to have
This is a real newbie question. I have simple app that selects a picture
I have a real simple form with a textbox and a button, and my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.