This is a discussion on "Help with array searching" within the JavaScript Forum section. This forum, and the thread "Help with array searching are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Help with array searching
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Hi
This will be an east one for all you experts. I've never done scripting/programming in any form before and am driving myself mad with this one!!!!!!! I need to search an array, which has 4 names in it, by inputting a string via window.prompt. If the name is not found I've got to ask them to re-enter their name. I'm not allowed to use a function as it's got to be straight code. I've also got another array with 4 entries and have to output the approriate message i.e. john is at names[0], therefore password is at password[0]. Hope this makes sense. womble |
|
|
|
|||
|
Re: Help with array searching
You can try adding something like this to your code, You'd have to adapt it to use window.prompt etc though.
Last edited by Blake121; Nov 24th, 2007 at 00:08. |
|
|||
|
Re: Help with array searching
Sounds like you need a Multi-Dimensionan Array. Or just 2 separate arrays. One for the names, and one for the passwords. 2 separate arrays will probably be easier with JavaScript than a multi-dimensional array. Then perform a loop and when you hit a match for the name, get the password from the password array at the same index. Just make sure you keep the names and the passwords at the same index in their array.
Good Luck, Scott |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Searching Blog | alexgeek | PHP Forum | 2 | Oct 27th, 2007 22:31 |
| php searching | corinne | PHP Forum | 6 | Jul 23rd, 2006 21:44 |
| searching help | corinne | Web Page Design | 5 | Jun 15th, 2006 11:00 |
| Sorting a new array from an existing array | Ozeona | Flash & Multimedia Forum | 2 | Sep 20th, 2005 08:43 |
| array unable to check another array so as to be displayed | Ozeona | Flash & Multimedia Forum | 1 | Aug 5th, 2005 10:26 |