Tasmanian Devil
06-22-2003, 11:15 AM
How do I make this script , when submitted, goes to a new page? I still need it to popup the window like it is in the script now. Just the first window to change to a different url?
<html>
<head>
<title>Log In</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
var expDays = 999999;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1) { endstr = document.cookie.length; }
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function cookieForms() {
var mode = cookieForms.arguments[0];
for(f=1; f<cookieForms.arguments.length; f++) {
formName = cookieForms.arguments[f];
if(mode == 'open') {
cookieValue = GetCookie('saved_'+formName);
if(cookieValue != null) {
var cookieArray = cookieValue.split('#cf#');
if(cookieArray.length == document[formName].elements.length) {
for(i=0; i<document[formName].elements.length; i++) {
if(cookieArray[i].substring(0,6) == 'select') { document[formName].elements[i].options.selectedIndex = cookieArray[i].substring(7, cookieArray[i].length-1); }
else if((cookieArray[i] == 'cbtrue') || (cookieArray[i] == 'rbtrue')) { document[formName].elements[i].checked = true; }
else if((cookieArray[i] == 'cbfalse') || (cookieArray[i] == 'rbfalse')) { document[formName].elements[i].checked = false; }
else { document[formName].elements[i].value = (cookieArray[i]) ? cookieArray[i] : ''; }
}
}
}
}
if(mode == 'save') {
cookieValue = '';
for(i=0; i<document[formName].elements.length; i++) {
fieldType = document[formName].elements[i].type;
if(fieldType == 'password') { passValue = ''; }
else if(fieldType == 'checkbox') { passValue = 'cb'+document[formName].elements[i].checked; }
else if(fieldType == 'radio') { passValue = 'rb'+document[formName].elements[i].checked; }
else if(fieldType == 'select-one') { passValue = 'select'+document[formName].elements[i].options.selectedIndex; }
else { passValue = document[formName].elements[i].value; }
cookieValue = cookieValue + passValue + '#cf#';
}
cookieValue = cookieValue.substring(0, cookieValue.length-4); // Remove last delimiter
SetCookie('saved_'+formName, cookieValue, exp);
}
}
}
</script>
<SCRIPT LANGUAGE="JavaScript">
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
if (username=="mbouali") { window.open('http:\/\/foxvalleynews.com/Mohamed Bouali/Mohamed Bouali.htm','','resizeable=yes,scrollbars=yes,menubar=no,width='+screen.width+',height='+screen.heig ht+',left=0,top=0');window.close(); done=1; }
if (username=="new user") { window.open('http:\/\/foxvalleynews.com/new user login.html','','resizeable=yes,scrollbars=yes,menubar=no,width='+screen.width+',height='+screen.heig ht+',left=0,top=0');window.close(); done=1; }
if (done==0) { alert("Invalid Username!"); }
}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=900,left = 300,top = 250');");
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" background="http://foxvalleynews.com/clouds.jpg" body onload="cookieForms('open', 'login')" onunload="cookieForms('save', 'login')">
<form name=login>
<table width=452 border=0 cellpadding=0 align="left">
<tr>
<td colspan=3 height="99">
<center>
<font size="+2"><b><font size="+5" face="Times New Roman, Times, serif">Please
Login</font><br>
</b></font><br>
<font face="Geneva, Arial, Helvetica, san-serif" size="3">If you are
a new user, just press the login button<br>
otherwise type in your username and then press the login button.</font>
</center>
</td>
</tr>
<br>
<tr>
<td width="75">Username:</td>
<td width="130">
<input type=text name=username value="new user">
</td>
<td width="239"> </td>
</tr>
<tr>
<td align=center width="75"> </td>
<td align=center>
<div align="center">
<input type=button value="Login!" onClick="Login()" name="button">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
Thanks
Devil
<html>
<head>
<title>Log In</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
var expDays = 999999;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1) { endstr = document.cookie.length; }
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function cookieForms() {
var mode = cookieForms.arguments[0];
for(f=1; f<cookieForms.arguments.length; f++) {
formName = cookieForms.arguments[f];
if(mode == 'open') {
cookieValue = GetCookie('saved_'+formName);
if(cookieValue != null) {
var cookieArray = cookieValue.split('#cf#');
if(cookieArray.length == document[formName].elements.length) {
for(i=0; i<document[formName].elements.length; i++) {
if(cookieArray[i].substring(0,6) == 'select') { document[formName].elements[i].options.selectedIndex = cookieArray[i].substring(7, cookieArray[i].length-1); }
else if((cookieArray[i] == 'cbtrue') || (cookieArray[i] == 'rbtrue')) { document[formName].elements[i].checked = true; }
else if((cookieArray[i] == 'cbfalse') || (cookieArray[i] == 'rbfalse')) { document[formName].elements[i].checked = false; }
else { document[formName].elements[i].value = (cookieArray[i]) ? cookieArray[i] : ''; }
}
}
}
}
if(mode == 'save') {
cookieValue = '';
for(i=0; i<document[formName].elements.length; i++) {
fieldType = document[formName].elements[i].type;
if(fieldType == 'password') { passValue = ''; }
else if(fieldType == 'checkbox') { passValue = 'cb'+document[formName].elements[i].checked; }
else if(fieldType == 'radio') { passValue = 'rb'+document[formName].elements[i].checked; }
else if(fieldType == 'select-one') { passValue = 'select'+document[formName].elements[i].options.selectedIndex; }
else { passValue = document[formName].elements[i].value; }
cookieValue = cookieValue + passValue + '#cf#';
}
cookieValue = cookieValue.substring(0, cookieValue.length-4); // Remove last delimiter
SetCookie('saved_'+formName, cookieValue, exp);
}
}
}
</script>
<SCRIPT LANGUAGE="JavaScript">
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
if (username=="mbouali") { window.open('http:\/\/foxvalleynews.com/Mohamed Bouali/Mohamed Bouali.htm','','resizeable=yes,scrollbars=yes,menubar=no,width='+screen.width+',height='+screen.heig ht+',left=0,top=0');window.close(); done=1; }
if (username=="new user") { window.open('http:\/\/foxvalleynews.com/new user login.html','','resizeable=yes,scrollbars=yes,menubar=no,width='+screen.width+',height='+screen.heig ht+',left=0,top=0');window.close(); done=1; }
if (done==0) { alert("Invalid Username!"); }
}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=900,left = 300,top = 250');");
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" background="http://foxvalleynews.com/clouds.jpg" body onload="cookieForms('open', 'login')" onunload="cookieForms('save', 'login')">
<form name=login>
<table width=452 border=0 cellpadding=0 align="left">
<tr>
<td colspan=3 height="99">
<center>
<font size="+2"><b><font size="+5" face="Times New Roman, Times, serif">Please
Login</font><br>
</b></font><br>
<font face="Geneva, Arial, Helvetica, san-serif" size="3">If you are
a new user, just press the login button<br>
otherwise type in your username and then press the login button.</font>
</center>
</td>
</tr>
<br>
<tr>
<td width="75">Username:</td>
<td width="130">
<input type=text name=username value="new user">
</td>
<td width="239"> </td>
</tr>
<tr>
<td align=center width="75"> </td>
<td align=center>
<div align="center">
<input type=button value="Login!" onClick="Login()" name="button">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
Thanks
Devil