Hello!
First time here, and I am in need of a little guidance.
I have the vision for my website, I just lack a little in the technical know-how.
Let me give you an idea of what's going on here, I have the intro page set up. My goal is to have a simple login page, a really simple, basic password protection concept. The result I'm looking for is an 'if, else if, else' type script, where certain passwords take you to certain pages. It's bare-boned, and not super secure, but that's okay. Nothing sensitive is being hosted, it's more of a stepping stone for bigger projects down the road.
I know a bit about HTML, and am coming along nicely with CSS, but Javascript is still for the most part over my head. This is my first time ever using Javascript, I kind of skipped over 'Hello World' and right to conditionals. I've got the idea mostly worked out, while consulting Google for assistance, but I can not get it to work right. Here's what I have so far.
Code:
<script language="javascript">
function loadPage(form) {
if (form.id.value=="1") {
open.document="newcustomer.php"
} else {
alert("Invalid password")
}
}
</script>
That's the script so far, it's located in the body, I've tried the head, to no avail. For ease with troubleshooting, the only acceptable password is '1,' this is so I know for certain that I'm putting in the right password. Also, this script as of now only has one acceptable password, when I finally get this working right, and add more pages, I'll add more 'else if's.'
Code:
<form name="form">
<CENTER><label for="enter">Enter Your Password:</label><input name="id" input type="text" class="box" name="pwd"/> <input type="submit" class="submit" onClick="loadPage(this.form)" value="Enter Now"/></CENTER>
</form>
This is the actual HTML markup for the form. Straight forward stuff here, just a simple text box (temporarily set to 'text' for the same troubleshooting assistance.)
The alert box does show up when an incorrect password is entered, but if I enter the correct password (1, in this case) the page simply refreshes, and
'pwd=1' appears at the end of the URL.
I'm puzzled, normally I can figure things out on my own, but this time I'm reaching out. Hopefully I've given you enough information, this is also my first attempt at looking for assistance for this sort of thing. If you need anymore, let me know!
Thanks for any and all help.
Bill
(Afterthought: I hit preview to make sure everything looked alright, then I noticed I have
'name=pwd' and
'input name=id' both in the form. I tried deleting the
'name=pwd' and trying again, same result, only
'id=1' appeared in the URL. Thought I had it there for a second, so close...
(Edit: Sorry, I posted without reading the post that tells you how to post. I'll put in descriptive titles in from now on...