Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
HTML Pages with CSS and JavaScript
Prototype question
John Farrel
Ranch Hand
Posts: 105
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have this function:
function indexOfOption(options, value) { for (var i=0;i<options.length;i++) { if (options[i].value == value) return i; } return -1; }
which I want to turn into a protoype method on a select.options array.
I thought I could do this:
function indexOfOption(value) { for (var i=0;i<this.length;i++) { if (this[i].value == value) return i; } return -1; } Array.prototype.indexOfOption = indexOfOption;
But that doesn't work. The method is not recognised.
What am I doing wrong?
John Farrel
Ranch Hand
Posts: 105
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
So no-one has any ideas?
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Unable to understand a code in a function?
Change cursor during Ajax
dynmicall adding row
copying from one select list to another
Adding Javascript global Variables to Http Request Session
More...