Click to See Complete Forum and Search --> : javascript questions'


gokou
01-08-2003, 04:39 PM
I know alot of javascript, but there are a few things' I just can't seem to understand. I've read through these in a book, but they are still confusing.

What is:

1. string/substring and the (#,#) that go with a substring

2. selectedIndex

I guess that's it for now. I thought there was more. I'll add more if I run into another problem.

AdamBrill
01-08-2003, 06:03 PM
Check out this code:

str="Split here|Rest of line";
str1=str.substring(str.indexOf('|')+1,str.length);
alert(str1);

The first line sets the string. the second line takes everything after the | and puts it into str1. Another way of doing this is like this:

str="Split here|Rest of line";
str1=str.split('|');

str1 is then an array that holds all of the parts of the line(split at the |). So, you could get what is before the first one like this:

alert(str1[0]);

And get what is after it like this:

alert(str1[1]);

and so on...

the selectedIndex tells which option it is on in a <select> tag. the first one is 0, second is 1, etc. Use it like this:

test=document.FormName.TagName.selectedIndex;

Also, a good place to find out how commands and stuff works is on http://msdn.microsoft.com I hope that helps...