say they enter "test"
save to a var name checkValue
var checkValue = document.myForm.txt.value;
your array would be something like
var myArray = new Array("something","somethingelse","somethingnew","test"
then loop through the array
for(var counter= 0; counter <= myArray.length; counter++){
if(checkValue == myArray[counter]) {
alert("evalue is eqaul to element "+counter+" in the array"
}
} _______________________________________________
[sub]{ str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee"alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924
has you're questio
you can do some modifications to the above to redirect the viewer to say page in the site.
so say you have a list of pages. test is one of them
have the text box and a label saying enter page you would like to visit.
in the body
<form name="myForm">
<input type="text" name="txtURL" onBlur="goURL(this.value)">
</form>
then your function would look like this
<script>
var myArray = new Array("something.htm","somethingelse.htm","somethingnew.htm","test.htm"
notice two new things here.
indexOf()
what we do here is check to see if the value in the array that is in reference a this point of the counter has the value of what was entered intot he tet box at all. note:if you enter something the first page is where you go. this was jsut a example and would not be good for pages with like names.
and
location.href
which is jsut a redirection function
O' and the break;
if you don't do a break in the loop you get a undefned error due to the loop still going. you need to stop the loop at the point of a match and this is how you would in javascript
also notice the declaration of the array outside the function. this makes it global and can be thus used in any function.
is this kind of what you had in mind? _______________________________________________
[sub]{ str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee"alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924
has you're questio
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.