简体   繁体   English

如何使用jquery / javascript从ontextchanged事件获取文本框值

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

How to get textbox value from their textchanged event using jquery/javascript. 如何使用jquery / javascript从其textchanged事件获取文本框值。 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 现在,当我运行此代码时,它显示一个错误,即Uncaught SyntaxError:无效或意外的令牌

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. 我没有得到正确的语法,甚至不知道此方法是否适合通过textchanged事件获取文本框值。

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 但是我怀疑从类中您正在实现自动完成插件,并且需要在该插件的API中工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过 Javascript 触发 asp:TextBox 的 ontextchanged() 事件 - Fire ontextchanged() event of an asp:TextBox via Javascript 如何获得所有文本框的焦点? 使用 javascript 事件而不使用 jquery - How to get focusin for all textbox? using javascript event not using jquery 未使用日历控件触发Textbox OnTextChanged事件 - Textbox OnTextChanged event not triggered using a calendar control 如何使用javascript获取具有更改事件的文本框的第一个值? - How to get first value of textbox with change event using javascript? 如何在JavaScript中的按键事件上获取文本框的值 - How to get the value of a textbox on keypress event in javascript 如何从在jquery或javascript中自动完成的文本框中获取价值 - How to get value from a textbox that being autocompleted in jquery or javascript 从文本框jquery / javascript的数组中获取单个文本框值 - get a single textbox value from array of textbox jquery/javascript 如何从表中的文本框中获取值并使用javascript更新它 - how to get the value from textbox in table and update it using javascript 如何使用Javascript从Gridview中的文本框中获取文本值 - How to get the text value from textbox which is in Gridview using Javascript 当javascript填充文本框中的值时调用onTextChanged函数 - Call onTextChanged function when javascript fills value in textbox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM