PDA

View Full Version : Html-javascript Help !!!


sillycheese
01-22-2005, 12:49 PM
I have a javascript code that I need jelp with. I have a log-in script on my home page that will allow users to log-in to a message board, but when they do, it stays within a frame. I want it to target "target='_top' but I don't know how to do it, or where to put the code at.

Here is where think it needs to go:

<input type='submit' name='submit' value='login' class='forminput'>

HERE IS THE FULL CODE:

<HEAD>
<script language="JavaScript">

var COOKIE_NAME = 'myforumiB';
var IB_URL = 'http://mysite.com/myforum.cgi';

function showLogin ()
{
// Read the memberid cookie.
var cookie = readCookie( COOKIE_NAME + 'iBUserName' );

// If cookie exists and has a value, welcome them back.
if (cookie)
{
document.write('<b><center>Welcome Back ' + cookie + '!</center></b>');
}

// If cookie doesn't exist, print login page.
else
{
document.write("<table><form action='" + IB_URL +"' method='post' name='LOGIN' onSubmit='return ValidateForm()'><input type='hidden' name='act' value='Login'><input type='hidden' name='CODE' value='01'><td>Username:<input type='text' size='12' align=right maxlength='64' name='UserName' class='forminput'>Password:<input type='password' align=right size='12' name='PassWord' class='forminput'>

<B><input type='submit' name='submit' value='login' class='forminput'></B>

Remember:<input checked type='checkbox' name='CookieDate' value='1'>Anonymous:<input type='checkbox' name='Privacy' value='1'></td></form></table>");
}
}

// Read cookie function.
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

// Checks login form for missing required info.
function ValidateForm()
{
var Check = 0;
if (document.LOGIN.UserName.value == '') { Check = 1; }
if (document.LOGIN.PassWord.value == '') { Check = 1; }
if (Check == 1)
{
alert("Enter Your NAME & PASSWORD You!!!!");
return false;
}
else
{
document.LOGIN.submit.disabled = true;
return true;
}
}
</script>

</HEAD>

<BODY>

<script language="JavaScript">showLogin();</script>

</BODY>

----------------

Please Help

Thanks.

Kravvitz
01-22-2005, 01:08 PM
The target attribute for a form goes on the <form> tag.

You know there are several sites that list the available attributes for each HTML element. Here is one such reference. (http://www.w3schools.com/html/html_reference.asp)

sillycheese
01-22-2005, 01:37 PM
Thanks, I went there but I do not understand. I looked at there example they showed on the "form" page, I am lost.

Kravvitz
01-22-2005, 02:10 PM
What do you not understand?

sillycheese
01-22-2005, 02:24 PM
I looked at the link you provided, and studied the code, but I dont understand how it fits into the code I already have.

Thanks.

Kravvitz
01-22-2005, 02:34 PM
So you didn't write the script that you are using?

document.write("<table><form action='" + IB_URL +"' method='post' name='LOGIN' target='_top' onSubmit='return ValidateForm()'><input type='hidden' name='act' value='Login'><input type='hidden' name='CODE' value='01'><td>Username:<input type='text' size='12' align=right maxlength='64' name='UserName' class='forminput'>Password:<input type='password' align=right size='12' name='PassWord' class='forminput'>

<B><input type='submit' name='submit' value='login' class='forminput'></B>

Remember:<input checked type='checkbox' name='CookieDate' value='1'>Anonymous:<input type='checkbox' name='Privacy' value='1'></td></form></table>");

sillycheese
01-22-2005, 05:40 PM
No I did not write that code. It puts a login box on the page you out it on, but I dont know how to specify it to make it target an html frame like ex. (target="_top") so that it doesnt get stuck in a frame after clicking the login button.

Thanks