Passing a text field value to asp.net javascript function

I find it a little difficult. Trying to pass textBox value to javascript function and get undefined.

Tip maybe on how I can get this variable in a function

<input type="image" runat="server" id="btnSearchFunction" src="Images/searchIcon.png" name="image" onclick="SearchContent();" width="16" height="20" /> <input type="hidden" name="searchValue" value="<%#txtSearch.Value %>" /> <input type="text" runat="server" id="txtSearch" name="searchValue" class="input-medium search-query" placeholder="Search ..."/> 

and this is the function I'm trying to pass to her

 function SearchContent() { var txtBoxValue = $(this).parent().find("input[name='searchValue']").val(); alert(txtBoxValue); } 
+4
source share
1 answer

How about something more direct:

 var txtBoxValue = $('#txtSearch').val(); alert(txtBoxValue); 
+3
source

Source: https://habr.com/ru/post/1493428/


All Articles