PDA

View Full Version : button



spyder
09-25-2005, 12:12 AM
i am using a form script and when you click the button it submits. i want to replace the button with a text link. please tell me if this is possible and what to replace the code with. also, is there a way that when you click into te box with the username, it selects all so that you can just type? and 1 more thing, can you set the "focus" an the submit button so that when you click enter, it submits it. thank you


<script>
//Encrypted Password script- By Rob Heslop
//Script featured on Dynamic Drive
//Visit http://www.dynamicdrive.com

function submitentry(){
password = document.password1.password2.value.toLowerCase()
username = document.password1.username2.value.toLowerCase()
passcode = 1
usercode = 1
for(i = 0; i < password.length; i++) {
passcode *= password.charCodeAt(i);
}
for(x = 0; x < username.length; x++) {
usercode *= username.charCodeAt(x);
}
//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(usercode==134603040&&passcode==126906300)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location=password+".htm"}
else{
alert("password/username combination wrong")}
}
</script>

<form name="password1">

<input type="text" name="username2" value="User Name" size="15">

<input type="password" name="password2" value="Password" size="15">

<input type="button" value="Submit" onClick="submitentry()">
</form>

jscheuer1
09-25-2005, 02:58 AM
This is real close:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<script>
//Encrypted Password script- By Rob Heslop
//Script featured on Dynamic Drive
//Visit http://www.dynamicdrive.com

function submitentry(){
password = document.password1.password2.value.toLowerCase()
username = document.password1.username2.value.toLowerCase()
passcode = 1
usercode = 1
for(i = 0; i < password.length; i++) {
passcode *= password.charCodeAt(i);
}
for(x = 0; x < username.length; x++) {
usercode *= username.charCodeAt(x);
}
//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(usercode==134603040&&passcode==126906300)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location=password+".htm"}
else{
alert("password/username combination wrong")}
}
</script>

<form name="password1" onsubmit="submitentry();return false;">

<input type="text" name="username2" value="User Name" size="15" onclick="this.select()">

<input type="password" name="password2" value="Password" size="15">

<input type="submit" value="Submit" style="border:none;color:black;background-color:white;">
</form>
</body>
</html>Submit is still a button but, it looks like text. The text shown is that of its 'value' attribute. Change its style to match the background-color and color of your page. Since it is now a submit button it will fire on hitting the enter key, as long as the user has already clicked on or otherwise brought focus to one of the other form elements. The name field will now self-select onclick.

spyder
09-26-2005, 12:35 AM
thank you. it is great