locked
input field value RRS feed

  • Question

  • User1519602350 posted

    Hi,

    How to get input field value with out pressing submit buton? Need to use any jquery for this?

    <input id='Hash' name='Hash' type='text' Value='sample' />
         
        
        @{
     
     
        var stem = Request["Hash"];
        var commandText = string.Empty;

    Appreciate your help

    Thanks

    Thursday, September 12, 2013 10:21 AM

Answers

  • User895691971 posted

    Hi, use this:

    Use jQuery to get the value like this: 

    var valueHash = $("#hash").val();

    Then send this value to server using Ajax, like this:

    // you can set the onKeyUp event as:
    
    <input type="text" id="hash" onkeyup="sendthis(this.value)" />
    
    // ajax will be..
    
    function sendthis(value) {
      $.ajax({
        url: "url_of_page",
        data: "value=" + value;
        success: function (result) {
          $("#result").html(result);
        }
      });
    }

    This way, you will send the data! And then, get the result of the Ajax as responseText. Its value will be the value in 

    Response.Write();

    Good luck!


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, September 14, 2013 1:32 AM

All replies

  • User1320044578 posted

    Yes, you can use jQuery for this like.

    $("#Hash").val();

    Thursday, September 12, 2013 10:25 AM
  • User1519602350 posted

    Yes, you can use jQuery for this like.

    $("#Hash").val();

    Then how can i pass to var stem = Request["Hash"];?

    Thursday, September 12, 2013 10:26 AM
  • User1320044578 posted

    You have to pass that value in server without submit click than use ajax.

    when you want to pass text value any conditions?

    Friday, September 13, 2013 10:17 AM
  • User-1980594115 posted

    I don't know if this is what you are looking for.  But you can use onChange or something similar to get an input field to post data without a submit button:

    @{
        if (IsPost){
            @:Stem: @Request["Hash"] <br />
        }
    }
    
    <form method="post">
        Sample Hash: <input name="Hash" type="text" id="Hash" value="sample" onChange="this.form.submit();" />
    </form>
    



    Friday, September 13, 2013 4:32 PM
  • User895691971 posted

    Hi, use this:

    Use jQuery to get the value like this: 

    var valueHash = $("#hash").val();

    Then send this value to server using Ajax, like this:

    // you can set the onKeyUp event as:
    
    <input type="text" id="hash" onkeyup="sendthis(this.value)" />
    
    // ajax will be..
    
    function sendthis(value) {
      $.ajax({
        url: "url_of_page",
        data: "value=" + value;
        success: function (result) {
          $("#result").html(result);
        }
      });
    }

    This way, you will send the data! And then, get the result of the Ajax as responseText. Its value will be the value in 

    Response.Write();

    Good luck!


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, September 14, 2013 1:32 AM