Answered by:
JavaScript array index of

Question
-
Hi Expert,
Crm is support java script. But i cannot understand Why does not support javascript array index of. Anybody facing with this problem?
I refer following code. And then i put to crm form save. it show
<html> <head><h1>JavaScript Array indexof </h1> <title>JavaScript array indexof </title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <script language="javascript" type="text/javascript"> var array=new Array(); array[0]="Rose"; array[1]="India"; array[2]=".net"; array[3]="Rohini"; document.write("<b>"+"Element in the array are "+"</b>"+ "<br />"); document.write("================="+ "<br />"); for(var i=0;i<array.length;i++){ document.write(array[i]+"<br>") } document.write("================="+ "<br />"); var index = array.indexOf("India"); document.write("<b>"+"Index of India on the array is: "+"</b>"+index); </script> </body> </html>
There was an error with this field's customized event. Error: Object doesn't support this property or method.
Here is Crm Js Code
var array=new Array(); array[0]="Rose"; array[1]="India"; array[2]=".net"; array[3]="Rohini"; var index = array.indexOf("India"); alert(index);
How can i get array index in CRM?
Best Regards,
Yukon
Make Simple & EasyThursday, April 28, 2011 2:38 AM
Answers
-
Hi All,
Thanks for your reply. I try with Pogo69 Method.
Thanks and Regards,
Yukon
Make Simple & Easy- Marked as answer by Yukonn Friday, April 29, 2011 3:19 AM
Friday, April 29, 2011 3:19 AM
All replies
-
Hi Yukon,
All Javascript functions are browser specifc some of the functions work in particular version of the browser. Please check the following URL, in this they specified which array funcion works in which browser with version. This may help you.
http://www.javascriptkit.com/jsref/arrays.shtml
For getting index of array element in CRM you may need to loop through array and find the index.
Thanks and Regards
Ramu
- Proposed as answer by Janu_m Thursday, April 28, 2011 3:39 AM
Thursday, April 28, 2011 3:39 AM -
IE does not support the Array.indexOf() method; see this article for the history/reasoning behind it.
You can implement it yourself:
if (!Array.indexOf) { Array.prototype.indexOf = function (obj, start) { for (var i = (start || 0); i < this.length; i++) { if (this[i] == obj) { return i; } } return -1; } }
--pogo (pat)- Proposed as answer by Can Bilgin Thursday, April 28, 2011 6:42 AM
Thursday, April 28, 2011 3:50 AM -
Hi All,
Thanks for your reply. I try with Pogo69 Method.
Thanks and Regards,
Yukon
Make Simple & Easy- Marked as answer by Yukonn Friday, April 29, 2011 3:19 AM
Friday, April 29, 2011 3:19 AM