0

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 i.e. 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.

1
  • onclick="ShowData(this.value)" Commented Aug 7, 2018 at 17:11

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.