indexof

understanding nested arrays in Javascript

£可爱£侵袭症+ 提交于 2019-12-25 03:00:46
问题 I want to create a nested array in Javascript but can't do the thing what I want, I don't know if it is even possible. Here is an example of what kind of array I want to create: var array = ['id1', 'id2', 'id3', 'id4']; Then I want to add new array for each id such way that id values stayed the same. Why? because I want to use indexOf method to find out the element index of main array with sub array id. Something like this: array[0]['par1'] should return the value of parameter1 array[0]['par2

c# IndexOf does not exist in current context

廉价感情. 提交于 2019-12-25 02:14:36
问题 I'm trying to use the following and can't wrap my head around why this IndexOf method isn't working. foreach (string s in regKey.GetSubKeyNames()) { RegistryKey sub = Registry.LocalMachine.OpenSubKey(string.Format(@"{0}\{1}", _UninstallKey64Bit, s), false); if (sub.ValueCount > 0) { values = sub.GetValueNames(); if (IndexOf(values, "DisplayName") != -1) { string name = (sub.GetValue("DisplayName") != null) ? sub.GetValue("DisplayName").ToString() : string.Empty; if (!string.IsNullOrEmpty(name

JS & jQuery: inArray() and indexOf() are not working properly if indexes are strings?

与世无争的帅哥 提交于 2019-12-25 01:47:15
问题 I have an array like this: var arr = []; arr['A string'] = '123'; arr['Another string'] = '456'; and Im trying to find an index of '123' or '456'. Both: var string = $.inArray('123', arr) and var string = arr.indexOf('123') are giving me -1. Is it possible to get it working when indexes are strings? 回答1: Like all Array methods and the length property, the indexOf method of an Array object only considers numeric properties of the Array. These are properties whose names are unsigned integers.

indexOf is not working in JavaScript

十年热恋 提交于 2019-12-24 10:45:28
问题 I am checking an index Of string in JAVASCRIPT. and this is coming as false. where as the value does belong to it as below : if(idOfControl.indexOf(idOfButton)) == is giving false for the below values. idOfControl = "dlInventory_btnEditComment_0" idOfButton = "dlInventory_btnEditComment" But if I run idOfControl.replace(idOfButton, ""); It is working and replacing the text. Any reason for this? 回答1: indexOf can also return 0, in the event of your string being found at the position 0 . 0

if input contains any word in array

♀尐吖头ヾ 提交于 2019-12-24 03:18:10
问题 I have an input and I want to know if any of the values in my array exist. For a simple example my array is var _array = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; I've figured out how to trigger it if I type simply 'sun' for example, but I want to know if 'hhsun' or 'sunee' exist too. $('input').keyup(function() { var _val = $(this).val(); $('p').text(_val); var _array = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; if (_array.indexOf(_val) != -1) { $('span').text('it worked');

For Each Loop through DataGridViewColumn Headers

做~自己de王妃 提交于 2019-12-24 03:06:06
问题 I have a DataGridView called DataGridViewHistorical that has columns for 2012 to 1900. I am trying to loop through the column headers and use the year to find a specific date in a string. So in the example below I would be looking for 2012-01-03, 2011-01-03, 2010-01-03 ... 1900-01-03. For Each columnYear As DataGridViewColumn In DataGridViewHistorical.Columns MessageBox.Show(strBuffer.IndexOf(columnYear & "-01-03")) Next When I run this code I get error "Operator '&' is not defined for types

How to check if array contains specific object [duplicate]

眉间皱痕 提交于 2019-12-24 01:42:56
问题 This question already has answers here : How to determine if Javascript array contains an object with an attribute that equals a given value? (23 answers) Closed last year . I am trying to check if array of objects contain a specific object or object with specific property. var mainArray = [ {name:"Yahya", age:"29"}, {name:"Ahmed", age:"19"}, {name:"Mohamed", age:"10"}, {name:"Ali", age:"32"}, {name:"Mona", age:"25"}, {name:"Shady", age:"62"}, {name:"Reem", age:"11"}, {name:"Marwa", age:"52"}

indexOf is not a function in Firefox, Opera but works in IE, indexOf alternative in javascript to test string contains?

ぐ巨炮叔叔 提交于 2019-12-23 07:51:44
问题 Getting an error using indexOf call in Javascript on Firefox and Opera. Works fine in IE. Following is the error message: Action function anonymous(Grid, Row, Col, Event) { return Grid.ActionShowPopupMenu(); } for event OnRightClick failed with exception: row.id.indexOf is not a function I'm testing that a string contains another string in Javascript and using the indexOf function of a string. The calls however are being made in JQuery functions. Perhaps that is the reason for the problem? Is

IndexOf with String array in VB.NET

本秂侑毒 提交于 2019-12-23 07:28:49
问题 How would I find the index of an item in the string array in the following code: Dim arrayofitems() as String Dim itemindex as UInteger itemindex = arrayofitems.IndexOf("item test") Dim itemname as String = arrayofitems(itemindex) I'd like to know how I would find the index of an item in a string array. (All of the items are lowercase, so case shouldn't matter.) 回答1: It's a static ( Shared ) method on the Array class that accepts the actual array as the first parameter, as: Dim arrayofitems()

Uncaught TypeError: .indexOf is not a function

别说谁变了你拦得住时间么 提交于 2019-12-23 06:48:09
问题 I am new to JavaScript and I'm getting an error as below. Uncaught TypeError: time.indexOf is not a function Gee, I really thought indexOf() really was a function. Here is a snippet of my code: var timeofday = new Date().getHours() + (new Date().getMinutes()) / 60; document.getElementById("oset").innerHTML = timeD2C(timeofday); </script> <script> function timeD2C(time) { // Converts 11.5 (decimal) to 11:30 (colon) var pos = time.indexOf('.'); var hrs = time.substr(1, pos - 1); var min = (time