Jump to content

Javascript. Help. Plz. Noob here.

MrChavelo

Hello guys,

 

I am just starting to get into java and I ran into a problem. I am scripting a website where you would have to submit. When I fill in the fields, and press the submit button nothing happens.

How can I fix this?

 

HTML:

<!DOCTYPE html>    <html>        <head>            <title>Javascript</title>            <link rel="stylesheet" type="text/css" href="css.css">            <script src="java.js"></script>        </head>        <body>            <div class="submitalign">                    <div class="submitbox" align="left">                    <span class="submitform">                        First name: <input type="text" name="fname"><br>                        <span style="position:absolute;left:1px;top:25px;">Last name: <input type="text" name="lname" id="lname"></span>                        <span style="position:absolute;left:3px;top:50px;">Username: <input type="text" name="uname" id="uname"></span>                        <span style="position:absolute;left:29px;top:75px;">Email: <input type="text" name="email" id="email"></span>                        <span style="position:absolute;left:6px;top:100px;">Password: <input type="password" name="password" id="password"></span>                        <span style="position:absolute;left:7px;top:125px;">Confirm</span><span style="position:absolute;top:142px;left:7px;">password: <input type="password" name="confirm" id="confirm"></span>                        <span style="position:absolute;left:75px;top:170px;"><button type="button" style="cursor:pointer;" onclick="func2()">Submit</button></span>                    </span>                </div>            </div>                <div class="content">                <div class="innerheader">                    <div class="innerfooter">                        <div onclick="func1()" class="start" align="center"><span class="startalign">No account?<br>Click here to submit</span></div>                    </div>                </div>            </div>        </body>    </html>

 

CSS:

body {                                    background-color: #A6ADAB;                    font-size: 16px;                    margin: 0;                    padding: 0;                    font-family: "Arial Black";                    height: 4000px;                    overflow: hidden;                }                                .start {                                    cursor: pointer;                    background-color: #D6D6D6;                    width: 150px;                    height: 150px;                    border: solid 1px #B9BDBC;                    border-radius: 75px;                    font-size: 1.3em;                    position: absolute;                    left: 50%;                    right: 50%;                    transform: translate(-50%, 0%);                    bottom: 0px;                                }                                .startalign {                                    position: relative;                    top: 40px;                                }                                .content {                                    background-color: #ABE0D0;                    position: absolute;                    height: 100%;                    width: 86%;                    left: 7%;                    right: 7%;                    border-left: 1px #B9BDBC solid;                    border-right: 1px #B9BDBC solid;                    box-shadow: 4px 0px 5px black, -4px 0px 5px black;                }                                .innerheader {                                    background-image: url("http://images7.alphacoders.com/413/413625.jpg");                    position: absolute;                    width: 95%;                    height: 100%;                    left: 2.5%;                    right: 2.5%;                                }                                .innerfooter {                                    position: absolute;                    left: 0px;                    right: 0px;                    width: 100%;                    height: 152px;                    bottom: 50px;                    background-color: #ABE0D0;                    border-top: 1px #B9BDBC solid;                    border-bottom: 1px #B9BDBC solid;                                }                                .submitalign {                                    position: absolute;                    height: 4000px;                    width: 100%;                                }                                .submitbox {                                    background-color: #ABE0D0;                    position: absolute;                    bottom: 40px;                    height: 600px;                    left: 350px;                    right: 350px;                    border-left: 1px #B9BDBC solid;                    border-right: 1px #B9BDBC solid;                    box-shadow: 3px 0px 6px black, -3px 0px 6px black;                                }                                .submitform {                                    position: absolute;                    left: 20px;                    top: 15px;                                    }

 

JS:

function func1() {                                    window.scrollTo(0,4000);                }                                    function func2() {                                    var fname = document.get.ElementById("fname").value;                    var lname = document.get.ElementById("lname").value;                    var uname = document.get.ElementById("uname").value;                    var email = document.get.ElementById("email").value;                    var password = document.get.ElementById("password").value;                    var confirm = document.get.ElementById("confirm").value;                                        if (fname === null) {                        alert('You must fill in all of the fields!');                    }                    else if (lname === null) {                        alert('You must fill in all of the fields!');                    }                    else if (uname === null) {                        alert('You must fill in all of the fields!');                    }                    else if (email === null) {                        alert('You must fill in all of the fields!');                    }                    else if (password === null) {                        alert('You must fill in all of the fields!');                    }                    else if (confirm === null) {                        alert('You must fill in all of the fields!');                    }                     else if (password !== confirm) {                        alert('The passwords do not match!');                    }                    else {                        confirm('Are you sure that you want to create the account '+uname +'?');                    }                                        window.open('http://www.google.com/');                }                                document.addEventListener("keydown", function (e) {                    if([37,38,39,40].indexOf(e.keyCode) > -1){                        e.preventDefault();                    }                }, false);

Project Pluto
i3 4170 MSI H97 PC Mate MSI R9 380 2GD5T @ 1095MHz Kingston HyperX Fury Blue 2x4gb @ 1600MhzWD 1TB Blue • be quiet! Pure Rock • NZXT S340 Black XFX TS 550w • BenQ GW2265HM

 

Link to comment
Share on other sites

Link to post
Share on other sites

chek the console for errors, also Java and Javascript are not the same so dont mix them up

I spent $2500 on building my PC and all i do with it is play no games atm & watch anime at 1080p(finally) watch YT and write essays...  nothing, it just sits there collecting dust...

Builds:

The Toaster Project! Northern Bee!

 

The original LAN PC build log! (Old, dead and replaced by The Toaster Project & 5.0)

Spoiler

"Here is some advice that might have gotten lost somewhere along the way in your life. 

 

#1. Treat others as you would like to be treated.

#2. It's best to keep your mouth shut; and appear to be stupid, rather than open it and remove all doubt.

#3. There is nothing "wrong" with being wrong. Learning from a mistake can be more valuable than not making one in the first place.

 

Follow these simple rules in life, and I promise you, things magically get easier. " - MageTank 31-10-2016

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

If it's codecademy you're talking about, I've always run into that problem, I just go back and try again

~Man is least himself when he talks in his own person. Give him a mask, and he will tell you the truth - Oscar Wilde~

Link to comment
Share on other sites

Link to post
Share on other sites

chek the console for errors, also Java and Javascript are not the same so dont mix them up

TypeError: document.get is undefined

 

 

What does this mean?

Project Pluto
i3 4170 MSI H97 PC Mate MSI R9 380 2GD5T @ 1095MHz Kingston HyperX Fury Blue 2x4gb @ 1600MhzWD 1TB Blue • be quiet! Pure Rock • NZXT S340 Black XFX TS 550w • BenQ GW2265HM

 

Link to comment
Share on other sites

Link to post
Share on other sites

If it's codecademy you're talking about, I've always run into that problem, I just go back and try again

No, it's not that, I am scripting a website for fun

Project Pluto
i3 4170 MSI H97 PC Mate MSI R9 380 2GD5T @ 1095MHz Kingston HyperX Fury Blue 2x4gb @ 1600MhzWD 1TB Blue • be quiet! Pure Rock • NZXT S340 Black XFX TS 550w • BenQ GW2265HM

 

Link to comment
Share on other sites

Link to post
Share on other sites

TypeError: document.get is undefined

 

 

What does this mean?

dont forget the document redy function and i think that means your not refrancing your javascript file proparly

I spent $2500 on building my PC and all i do with it is play no games atm & watch anime at 1080p(finally) watch YT and write essays...  nothing, it just sits there collecting dust...

Builds:

The Toaster Project! Northern Bee!

 

The original LAN PC build log! (Old, dead and replaced by The Toaster Project & 5.0)

Spoiler

"Here is some advice that might have gotten lost somewhere along the way in your life. 

 

#1. Treat others as you would like to be treated.

#2. It's best to keep your mouth shut; and appear to be stupid, rather than open it and remove all doubt.

#3. There is nothing "wrong" with being wrong. Learning from a mistake can be more valuable than not making one in the first place.

 

Follow these simple rules in life, and I promise you, things magically get easier. " - MageTank 31-10-2016

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

document.get simply doesn't exist. what you meant is document.getElementById

confirm doesn't exist either. you have to write window.confirm

and you forgot to set the id of fname

 

btw, html offers the <form>tag which would make styling easier and would bundle your data automatically to a get or post call, js calls are possible too. i suggest reading into that

Eiffel: The most useful programming language ever

Link to comment
Share on other sites

Link to post
Share on other sites

If something is undefined, it means either that a variable with that name has not been assigned a value, or a function does not exist with that name. In this case, there is no function document.get().

Link to comment
Share on other sites

Link to post
Share on other sites

If something is undefined, it means either that a variable with that name has not been assigned a value, or a function does not exist with that name. In this case, there is no function document.get().

In Javascript, sometimes it also means you forgot a ' } '.

Link to comment
Share on other sites

Link to post
Share on other sites

In Javascript, sometimes it also means you forgot a ' } '.

 

Indeed. I love javascript.

Link to comment
Share on other sites

Link to post
Share on other sites

document.get simply doesn't exist. what you meant is document.getElementById

confirm doesn't exist either. you have to write window.confirm

and you forgot to set the id of fname

 

btw, html offers the <form>tag which would make styling easier and would bundle your data automatically to a get or post call, js calls are possible too. i suggest reading into that

I know about the html forms, but I just wanted to try it out with javascript

Project Pluto
i3 4170 MSI H97 PC Mate MSI R9 380 2GD5T @ 1095MHz Kingston HyperX Fury Blue 2x4gb @ 1600MhzWD 1TB Blue • be quiet! Pure Rock • NZXT S340 Black XFX TS 550w • BenQ GW2265HM

 

Link to comment
Share on other sites

Link to post
Share on other sites

TypeError: document.get is undefined

 

 

What does this mean?

On lines 8-13, you've put

var fname = document.get.ElementById("fname").value;

but document.get.ElementById isn't defined - you almost certainly meant document.getElementById (no . between the get and ElementById), so that block changes to

                    var fname = document.getElementById("fname").value;                    var lname = document.getElementById("lname").value;                    var uname = document.getElementById("uname").value;                    var email = document.getElementById("email").value;                    var password = document.getElementById("password").value;                    var confirm = document.getElementById("confirm").value;

If you change that, your code should start working.

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×