Jump to content

AndyB

Member
  • Posts

    37
  • Joined

  • Last visited

Posts posted by AndyB

  1. do you have a <body> ... </body> section to your code? What you've posted is just the <head> section, and I'd expect that you also need a <body> and a form with an email address field.

     

    Hi Ben,

    Thanks for your insight, I realised I hadn't added the form with the e-mail address field.

    Here's the code I reworked:

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0

    Transitional//EN">

    <HTML>

    <HEAD>

    <TITLE>E-MAIL INFO</TITLE>

    </HEAD>

    <BODY>

    <script LANGUAGE="JavaScript">

    <!--

    function showUpper(checked) {

    var showThis;

    if (checked) {

    showThis = document.myForm.name.value.toUpperCase();

    } else {

    showThis = document.myForm.name.value.toLowerCase();

    }

    document.myForm.name.value = showThis;

    }

    function emailTest(form) {

    if (form.email_address.value.indexOf("@", 0) < 0) {

    alert("This is not a valid e-mail address!");

    } else {

    alert("This could be a valid e-mail address");

    }

    }

    //-->

    </SCRIPT>

    <FORM NAME="myForm">

    Name:<BR>

    <INPUT TYPE="text" SIZE="30" NAME="name">

    <INPUT TYPE="checkbox" NAME="upperCheckbox"

    onClick="showUpper(this.checked);">

    Covert string to uppercase or lowercase<BR>

    Email address:<BR>

    <INPUT TYPE="text" SIZE="30" NAME="email_address">

    <INPUT TYPE="checkbox" onclick="(this.checked) ?

    emailTest(this.form) : '';">

    Test for email address<BR>

    </FORM>

    </BODY>

    </HTML>

    The first field turns the user's name to upper case

    The second field forces the user to input the @ sign in the e-mail address.

    How can I modify the email Test function to ensure that it contains the .com suffix?

    Also Ben,when I reply to your mails, I click:

    -'Reply'

    -start typing after the /quote part of your reply

    -Click 'Add reply'

    How can I :

    -Reply to you without having your last mail attached to my reply?And

    -Does my reply appear on the forum or are we in a private conversation?

    Thanks for your help Ben,

    Regards,

    Andy.

     

  2. As a general rule, keep your Javascript in an external file. It's much easier to have all your HTML files link to one central Javascript file -- that way, if you need to make edits that affect multiple pages, you can make the change to one file, not several.

     

    There are CSS libraries, but not really for adding styling such as colors, images, etc, since those will change significantly depending on the website. Most framworks out there are either for layout (see http://960.gs/ and similar) or for adding additional functionality by using other languages such as Ruby to modify how CSS is written (to add variables, math, etc.) For example, look at SASS (http://sass-lang.com/) and LESS http://lesscss.org/. I'm not really personally a fan of CSS frameworks, but some people like them.

    Hi Ben,

    I hope you're well and that your work is going OK too.

    Thanks for your reply to my last CSS query.

    I went to the "free CSS templates"site as you suggested and downloaded a template that I'm working on at the moment.

    I've got a code query that I was hoping you might be able to help me with.

    I'm trying to modify the e-mail Test(Form) in this code snippet but I get nothing displayed at all.

    I'd be grateful to have your insight on the error I made here.

    Many thanks Ben,

    Andy.

     

    <HTML>

    <HEAD>

    <TITLE>E-mails</TITLE>

     

    <script LANGUAGE="JavaScript">

     

     

    function emailTest(form) {

    if (form.email_address.value.indexOf("@", 0) < 0) {

    alert("This is not a valid e-mail address!");

    } else {

    alert("This could be a valid e-mail address");

    }

    }

     

    </SCRIPT>

     

    </HEAD>

     

     

    </HTML>

     

     

     

     

     

     

  3. Sounds like you are asking less about CSS specifically, and more about design related resources. Here are a couple resources:

     

    -- There are a huge number of CSS based templates online, both free and paid. A little Google searching should give you a wide range to play with.

     

    -- Fonts: http://www.fontsquirrel.com/ and http://www.dafont.com/

     

    -- Color options: http://kuler.adobe.com/ and http://www.colourlovers.com/

     

    -- Free stock photography: http://www.morguefile.com/ and http://www.sxc.hu/ (though you'll often end up purchasing stock photography from Dreamstime or iStockPhoto)

     

    I imagine you can also find a lot of resources by searching for "design freebies".

     

    Hi Ben,

    I hope you 're alright and that your work is going fine too.

    I've been getting into the killer.sites practical section of the JavaScript for Beginners tutorials.

    I've put to practice some of the code on validating forms and used the GetElementbyId and InnerHTML functions to toggle menus.

    I'm into the external JavaScript section now and I have a couple of questions I hope you might be able to answer.

    -Is using external JavaScript files the preferred method of using JavaScript?

    Stefan mentions that it is almost always done with CSS, so I was wondering if,when using manual JavaScript,it is best to have it written in an external file.

    My second question is sort of a follow up on my last post.

    Stefan mentions Scriptaculous and jQuery as external libraries that you can link your pages to, to do form validation and create widgets for JavaScript.

    When I was asking about "pre-existing CSS background images etc..."I was thinking about CSS libraries but formulated it poorly.

    I will go and look it up on the Internet,but

    -Are there any CSS libraries that you could recommend?

     

    Thanks in advance for your help Ben,

    Regards,

    Andrew.

     

     

     

  4. Hi Ben,

    I hope you're well and that work is going fine too.

    I was hoping you might be able to help with this query.

    I think I have the basic HTML skills more or less in place, whereby I can write basic HTML pages with tags and elements.

    Ideally, I would like to build a site, perhaps in view of putting together something I can show friends and improve on.

    I'm learning JavaScript forms at the moment with the Killer Sites tutorials, to add functionality to the site.

    I realise that my CSS is not very good though.

    I was wondering if there were resources available on the Net with good CSS templates that you could use to build your own sites.

    You obviously know that CMS 's use that principle, in Wordpress for example

    Could you possibly point us towards pre-existing CSS background images, fonts,colour shades?

    Many thanks Ben,

    Regards,

    Andy.

  5. A button is contained within the <form>, so in that sense, yes, the button is part of the form.

     

    In the above code, you are creating a form that contains a button, and when the button is clicked, Javascript is used to call myFunction() that shows the alert. The only thing part of this that is actually Javascript are these two portions:

     

    onClick="myFunction();"

    and

     

    <script LANGUAGE="JavaScript">
    
    function myFunction() {
    alert("The function has been called.");
    }
    
    </SCRIPT>

    If you haven't already, I would suggest that you do a little research on HTML/CSS before you do Javascript. You'll be working a lot with HTML/CSS when you are doing Javascript, so I'd suggest that you be generally comfortable with HTML/CSS so you're only confused with one language rather than three all at once.

     

    Thanks a lot for taking the time to look at this code Ben, it helped make things clearer and I'm going to brush up on my HTML/CSS too ,

    Regards,

    Andy.

     

     

     

  6. Seems like you are pretty much asking "what is the difference between PHP and Javascript."

     

    Javascript is a client side language, which means it executes its code directly within the browser. Javascript can be run at any time after the page has loaded. All Javascript code is visible to the visitor if they look for it, and Javascript can be changed/disabled by the visitor, meaning it isn't necessarily secure, and you can't always guarantee someone will have Javascript enabled. Javascript is used for things like animation (some of the stuff that Flash is able to do Javascript can do as well), interactive elements, slideshows, popups, form validation, etc. Basically, Javascript is often used when you need an extra layer of interactivity.

     

    PHP is a server side language, meaning that the server processes the code on the server, and returns the results to the browser. The code only runs when the page is first loaded, and the code isn't visible/can't be changed by viewers. PHP gives you significantly more functionality, including sending email, submitting and processing forms, logging in/out users, image creation and processing, etc.

     

    AJAX uses a mix of both PHP and Javascript. Basically, it uses Javascript to call PHP code, so you get the best of both worlds: you can call it whenever you want after the page loads, it doesn't require a page refresh, and you get access to PHP's wider range of functionality. You can't always guarantee that users will have Javascript enabled (though it's probably enabled on 99% of all machines.)

     

    When do you use these languages? I use HTML/CSS as the core (since all websites ultimately display HTML/CSS), PHP to add logic/functionality, and Javascript to add interactivity. Javascript and PHP aren't mutually exclusive, so for example, just because you are using Wordpress doesn't mean you won't be working with Javascript.

     

    Hi Ben,

     

    Thanks for your reply to my last post and breaking down the differences between JavaScript and PHP to me.

    I will try to illustrate the kind of little JavaScript bits I try to use to add functionality to my attempts at putting a site together.

     

    <HTML>

    <HEAD>

    <TITLE>Button</TITLE>

     

    <script LANGUAGE="JavaScript">

     

    function myFunction() {

    alert("The function has been called.");

    }

     

    </SCRIPT>

     

    </HEAD>

     

    <BODY>

     

    <HR>

     

    <FORM NAME="myForm">

    <INPUT TYPE="button" VALUE="call function" onClick="myFunction();">

    </FORM>

     

    </BODY>

    </HTML>

     

    I've picked up that bit from a manual explaining how to "write" buttons for a user to click on.

     

    My query is(and I apologise in advance for the clumsy formulation)is the button a part of the <FORM> element ?

    I know I've got a button named"call function" that comes up and when I click it, I get the alert box that says "The function has been called", but I'm not exactly sure which bits of code do what.

     

    Thanks in advance for your help with this matter,

    Regards,

    Andy.

     

     

  7. Hi Ben,

    Thanks for the tip on the J Query course, I'll look it up as soon as I'm done with the JavaScript course.

    I've got a question which I might not be able to formulate very well, but I'll try to anyway.

    If I'm not mistaken,PHP is the language used for Facebook, YouTube and WordPress.

    You may know someone who needs to update a WordPress site for example.

    If you're a PHP coder your skills can be used in that context I would imagine.

    Similarly, if you become fairly competent with the JavaScript skills available in the course, in which context can you use those skills?

    I seem to understand that JavaScript is useful to write forms for example, which is what I intended to use it for in my own site.

    I appreciate that my question is probably a bit vague but I would be grateful if you could exemplify the use of JavaScript in Web development.

    Many thanks Ben,

    Andrew.

     

    PS; Sorry about the reply blunders, I hope I've got it right this time, I used to click the "Add Reply" button at the bottom of the page!

  8. Hi Ben,

    Thanks for your kind greetings and your very prompt reply.

    I checked the code and Stefan's video and you were right on the money.

    The mistake was indeed" 1<10" as opposed to "i<10".

    Obviously, "i" is the variable and I didn't call it in the "for" loop!

     

    Cheers for your insight Ben.

    Could you possibly confirm if there is a JavaScript forum on the site?

     

    Best regards,

    Andy.

  9. Welcome to the forum!

     

    The issue is with this line:

     

    for(var i = 1; 1<10; i++)

     

    the third section (1 < 10) tells the loop to continue looping until 1 (one) is less than 10. Since 1 is always less than 10, you'll get an infinite loop. Instead of 1, you want to use your variable name, "i". Make sense?

  10. Hi guys,

    My name is Andy,I've just started learning JavaScript and I'm new to the Killer Sites community.

    I've got Web developer friends here in Brighton,England where I live and I enjoy tinkering with code a lot.

    I'd like to learn the ropes to try and make myself useful in that community and start building stuff.

    I discovered Stefan's videos on YouTube and I think his work is awesome for beginners like me.

    He recommends joining the community that's been built around his site, so here I am!

    This is my first post, so I apologise if it's below the community's standards.

    I have a coding query and I would be grateful for anyone's help with it.

    In the JavaScript for Beginners video there's a chapter on Loops.

    Both the "while" loop and the "for" loop are explained with code bits.

    I use Google Chrome as my browser and I've run code from other videos just fine.

    Somehow,the "for" loop code is going into what Stefan refers to as the "endless loop."

    After trying to run the code a couple of times,my browser crashed on me and I had to restart the PC.

    Anyway,this is the code that I copied from the video tutorial into Notepad this morning:

     

    for(var i = 1; 1<10; i++)

     

    {

    document.write(i + "<br> ");

     

    }

    Is the syntax not correct for the Google Chrome browser perhaps?

    I've actually run the code in IE8 and Firefox and got error messages too.

    I'd be grateful for anyone's insight on this code error.

     

    Thanks a lot everybody,

    Andy.

    PS: I'd be happy to receive advice about sorting out my profile data too.

    I'd like to fall in line with the community's expectations in that respect.

    Thanks.

×
×
  • Create New...