JavaScript Fundementals

Discussion in 'CIW Certifications' started by Mix'Creations, May 8, 2009.

  1. Mix'Creations

    Mix'Creations Nibble Poster

    56
    0
    28
    Hi all!

    Im currently learning JavaScript via SkillsTrain, and so up to date im on Section 2 Part A, i do have slight problems coding up (though i do understand and write about 80%) but nowt major.

    Anyway, the reason im writing this is that at the end of Lesson 5 your given an Application project to test what you have learnt, thus ok, but its asking me to experiment with various techniques to present images, i may be missing something here but as i have only followed material and not exactly coded script myself, i am Zumped (baffled, lost, confused) by this, i do know coding elements etc (obviously) but how to put them together is another thing.

    Please help.


    Mix'Creations.


    Ps: I know the properties and elements of the image object, to which i am referring to, but not exactly how to code them together.As in the example code below, where would you put the length property, and how, i know the rest, but this ones doing my head in.

    Here's the coding, many thanks:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <HTML>
    <HEAD>
    <TITLE>Lesson 5 Application Project</TITLE>

    <SCRIPT LANGUAGE="JavaScript">
    <!--

    function display_image(selectedImage) {

    var selectionName = selectedImage.options[selectedImage.selectedIndex].text;
    var selection = selectedImage.options[selectedImage.selectedIndex].value;

    myWindow =window.open("", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=200,height=295");

    myWindow.document.open();
    myWindow.document.write("<HTML><HEAD><TITLE>Micks Image</TITLE>\n");
    myWindow.document.write("</HEAD><BODY BGCOLOR='yellow' TEXT='red'>\n");
    myWindow.document.write("<DIV ALIGN='CENTER'><H3>" + selectionName + "</H3><HR>\n");
    myWindow.document.write("<IMG HEIGHT='150' WIDTH='150' SRC='" + selection + "'>\n");
    myWindow.document.write("<HR><FORM><INPUT TYPE='button' class='button' VALUE='OK' " +
    "onClick='window.close()'></FORM>\n");
    myWindow.document.write("</DIV></BODY></HTML>");
    myWindow.document.close();
    myWindow.moveTo(200,200);
    myWindow.focus();
    }

    //-->
    </SCRIPT>

    </HEAD>

    <BODY>
    <H3>CIW Web Languages</H3>
    <HR>

    <B>To preview, select an image name from the list.

    <P>

    <FORM NAME="form1">
    <SELECT NAME="imageName" onChange="display_image(this); this.selectedIndex=0;">
    <OPTION>Select An Image
    <OPTION VALUE="images/mountains.jpg">Mountains
    <OPTION VALUE="images/trees.jpg">Trees
    <OPTION VALUE="images/sunset1.jpg">Sunset
    </SELECT>
    </FORM>

    </BODY>
    </HTML>
     
    Certifications: 1D0-510) CIW Web Foundations Associate,
    WIP: On route to Guru

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.