Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Advanced website project

I'm having some trouble getting the code to work in my version of the advanced smells like bakin project. I downloaded the project files and I've been adding code to the pages, following Andrew in his videos. When I refresh in my browser, nothing happens. Has anyone else had trouble with this? any suggestions of things to look at?

3 Answers

Samuel Johnson
Samuel Johnson
9,152 Points

Are you using Mamp/Zamp as a local server for the .php files?

Hi Samuel, thanks for your response. I'm pretty new at this and I'm not sure what your question means. can you explain it?

Eduardo Garcia
Eduardo Garcia
4,571 Points

What Samuel meant is if you had server software installed for your PHP files, but from looking at your profile you haven't started any PHP work yet. My best guess is that you have a syntax error in your Javascript, I've sometimes had display problems when I missed a semicolon here or there in jQuery and sometimes wouldn't even let me load the website.

Samuel Johnson
Samuel Johnson
9,152 Points

Thanks Eduardo, I was getting a little confused because i thought you meant the php website 'Mikes T-Shirt'. But if you have not done any php then it wont matter and the issue is probably due to something in your code? Might be helpful to see some of it on here? Like Eduardo said if you miss a semi-colon, bracket or even space in the wrong place sometimes code will not load correctly!

here's the code that I have for the contact page on the smells like bakin' advanced website project. It deals with having the labels for each field in the email for being hidden and appearing when you place the cursor in the field. Also, making sure that the email is valid before it will let you submit. Any help is appreciated!

                <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript" src="js/validEmail.js"></script>
        <script type="text/javascript">
            var $submit = $(".submit input");
            var $required = $(".required");
            function containsBlanks (){
                var blanks = 
                $.required.map(function(){($(this).val() == "");
                });
                return $.inArray(true, blanks) !=-1;
            }


            function requiredFilledIn() {
                if(containsBlanks()) || !$("#email").validemail())) 
                    $submit.attr("disabled", "disabled");
                else 
                    $submit.removeAttr("disabled");
            }
            $("#form span").hide();
            $("input, textarea").focus(function(){
                $(this).next().fadein("slow");
            }).blur(function(){
                $(this).next().fadeout("slow");
            }).keyup(function(){
                //check all required fields.
                requiredFilledIn();
            });
            $("#email").validEmail({on:"keyup", success:function () {
                $(this).next().removeClass("error").addClass("valid");
            }, failure: function(){
                $(this).next().removeClass("valid").addClass("error");
            }});
            $("#email").keyup(function(){
                //Check for a valid email.

            requiredFilledIn();
            </script>
    </body>
    </html>
     ```