简体   繁体   中英

how to get textbox value from ontextchanged event using jquery/javascript

How to get textbox value from their textchanged event using jquery/javascript. I tried many things but didnt work. The last is I try, Here is the following code

@for (int i = 0; i < Model.MaterialRecordRowCount; i++)
{
    <div class="form-group row">
            <div class="col-sm-3">
            <input type="text" id="Material_PartNo@(i)" name="Material_PartNo@(i)" data-provide="typeahead"                 class="typeahead search-query form-control autocomplete" placeholder="PartNo" onclick="ShowData                 ('$('#Material_PartNo@(i)').val()')" />
                </div>
    </div>
}

function ShowData(PartNo) {
    alert(PartNo);
}

Now when I run this code it shows an error ie Uncaught SyntaxError: Invalid or unexpected token

I am not getting the right syntax even dont know that this method is right for getting the textbox value by their textchanged event or not.

Change

onclick="ShowData('$('#Material_PartNo@(i)').val()')"

To

onclick="ShowData(this.value)"

however I suspect from the classes you are implementing an autocomplete plugin and need to work within the API of that plugin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM