grep to match whole number

155
January 25, 2018, at 06:11 AM

Can you help me fix my problem?

I need to only return the data below that has a 1 value. Currently it will return 1 and 10 in my example below.

If I search 10 I get just 10 back but if I search 1 I get 1 and 10.

var searchIn = [{"curAction":"10"},{"curAction":"1"},{"curAction":"5"}];
var searchTerm = "1";
var filtered_result = $.grep(searchIn, function(myobj, i) {
    return (myobj.curAction.indexOf(searchTerm) > -1);
});
storage = JSON.stringify(filtered_result); // Set the resulting JSON 
string as the echo string, input
alert(storage);

JS FIDDLE

Rent Charter Buses Company
READ ALSO
How to display a WP custom field from ACF on a page depending on the link

How to display a WP custom field from ACF on a page depending on the link

I will try to explain my problem simply and quickly:

165
Saving data using Jquery or Javascript

Saving data using Jquery or Javascript

Is there any way to save variables using Jquery or javascript, besides setlocalstorage? For example: I have a product catalog website onlineI made administration rights features like a window where you can add the name, picture and price of an item

234
Burst control over multiple ajax requests

Burst control over multiple ajax requests

I have a list of $get requests that I handle using

225
How can i send and set datatable using an external javascript method

How can i send and set datatable using an external javascript method

I have a datatable which contains in the first cell of each row a checkboxI want to send an array of indexes to an external js function and check the checkboxes at the corresponding indexes

260