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 8064175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:17:25+00:00 2026-06-05T11:17:25+00:00

My view has a single textbox which captures scans from users. The scans will

  • 0

My view has a single textbox which captures scans from users. The scans will then be passed without any further user action to another action that will then use the scanned data to complete the transaction. So far, the textbox gets populated with the scan and immediately does redirect but without the contents of the textbox. This is what I have;

View:

<input id="thisText" class="largetext" name="txtScanLabel"  onkeyup="myKeyUp" />

And:

  <script type="text/javascript">
   var tResults = "Test";

       $(function () {
           $('input.largetext').focus();
       });

       $(function () {
           $("#thisText").keyup(myKeyUp);
       });

       function myKeyUp(eventInstance) {
           var myURL = '@Url.Action("ScanResults", "Home")';
           window.location.href = myURL + '?tResults' + encodeURIComponent(tResults);
       }

   </script>

Controller:

    public ActionResult ScanResults(string tResults)
    {

        var test = tResults;                     

        return RedirectToAction("Success");

    }
  • 1 1 Answer
  • 0 Views
  • 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-06-05T11:17:28+00:00Added an answer on June 5, 2026 at 11:17 am

    You have unobtrusively subscribed to the .keyup event handler with jQuery and yet you have used the onkeyup attribute in your DOM. You don’t need to do those two things. Using jQuery is enough. So start by cleaning your markup:

    <input id="thisText" class="largetext" name="txtScanLabel" />
    

    Also you have hardcoded the tResults value to Test in your javascript. Instead of using this hardcoded value from the global variable (that you could get rid of) you should read the value from the textbox:

    function myKeyUp(eventInstance) {
        var myURL = '@Url.Action("ScanResults", "Home")';
        var value = $(this).val();
        window.location.href = myURL + '?tResults=' + encodeURIComponent(value);
    }
    

    Notice that using window.location.href will immediately redirect to the ScanResults controller action when the user types something into the input field. You probably want to use AJAX:

    function myKeyUp(eventInstance) {
        var myURL = '@Url.Action("ScanResults", "Home")';
        $.ajax({
            url: myURL,
            type: 'POST',
            data: { tResults: $(this).val() },
            success: function(result) {
                // do something with the result returned by the controller action
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a View that has a single TextBox and a couple Button s
I have a single view which has a menu on the left hand side
I have senario in which one view and view has binding with multiple ViewModel.
My view page has a Model which is represented by a List of Students.
I have built an android application which has a single mapview. I have a
I would like to create a view that has a single column. If my
I want to add table view in my view based application, which has a
I wrote a simple ios5 application (includes garbage collector) that has a single view
The ActiveScaffold list view has a search form that is loaded via ajax when
My app's main view has a uiwebview. It is white for a split second

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.