Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

password validation and returning URL from a list menu

Status
Not open for further replies.

jreinard

Technical User
Feb 21, 2001
24
0
0
US
I am tring to get the following script to return the value of the listbox's URL once the password has been validated. For some reason it will not return the URL. Please Help!!!

<SCRIPT language=&quot;JavaScript&quot;>
<!--hide
function password()
{

var password;


var pass1=&quot;pass1&quot;;
var pass2=&quot;pass2&quot;;

password=prompt('Please enter you password below to authenticate entry.',' ');

if (password == pass1 || password == pass2 )
{return;}
else
{
alert('The password you have entered is invalid!');
}


}
//-->
</SCRIPT>



<!---- the form ---->


<form name=&quot;form2&quot; method=&quot;post&quot; action=&quot;&quot;>
<select name=&quot;select&quot; onChange=&quot;password()&quot;>
<option>select</option>
<option value=&quot;test1.asp&quot;>test1</option>
<option value=&quot;test2.asp&quot;>test2</option>
</select>
</form>
 
if (password == &quot;pass1&quot; || password == &quot;pass2&quot; )
{return return;}
else
{
alert('The password you have entered is invalid!');
return false;
}


onChange=&quot;return password()&quot;>


_______________________________________________
[sub]{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924

 
or if you compare the variable
password = pass1 || password = pass2 _______________________________________________
[sub]{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924

 
apologies I'm in boolean world
password == pass1 || password == pass2 is correct _______________________________________________
[sub]{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924

 
ok, jsut reread your question, what url? the current url or the value in the list box _______________________________________________
[sub]{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924

 
is this what you are looking for
function password()
{

var password;


var pass1=&quot;pass1&quot;;
var pass2=&quot;pass2&quot;;

password=prompt('Please enter you password below to authenticate entry.',' ');

if (password == pass1 || password == pass2 )
{ alert(document.form2.select2.options[document.form2.select2.selectedIndex].value);return true;}
else
{
alert('The password you have entered is invalid!');
return false;
}


}

don't name a select with the name select. restricted word maybe ?!?
notice the change to select2 _______________________________________________
[sub]{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924

 
I need to return the URL value in the listbox
 
this does return the value. But it returns the value in an alert box. I need it to open the page in the browser window?


Thanks in advance.
 
change

alert(...);
to
window.location=&quot;...&quot;;


-Rob
 
yes I know it did. I was giving you the example of how to get the value to use it. _______________________________________________
[sub]{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top