Jump to content

Javascript help, school asigment

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
vanhansen

vanhansen

    Newbie

  • Members
  • Pip
  • 2 posts
Hi guys! I got a school asigment. I'm a bit behind, so I need alot of help!

The first task is to make a HTML site where the user can type in his name and make a cookie. The user should also be informed if a cookie already exists, and delete the cookie if.

The second task is to make a HTML site where the users can put "movies" in to a shopping basket. The user should always be able to see whats in the basket and remove the "movies"..

The thierd and last task is to make a bunch of moving pigs and be able to move them into a spesific location.

Could someone please help me! Add me on msn (s_t_i_a_n@hotmail.com) or talk to me on this forum. I'm in despret need for help! :)

I'm studying webdesign at NITH in Oslo, Norway.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What do you have so far?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
vanhansen

vanhansen

    Newbie

  • Members
  • Pip
  • 2 posts
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Oppgave 1</title>

<style type="text/css">

#main
{
    width: 500px;
    height: 500px;
    margin: auto;
    background-image:url(bilder/cookie_bg.png);
    background-repeat:no-repeat;
}
    
    #main_header
    {
        width: 310px;
        margin: auto;
        padding-top: 30px;
    }
    
    #info
    {
        width: 480px;
        margin: auto;
        text-align: center;
        padding-top: 30px;
    }
    
    #text_box
    {
        width: 480px;
        margin: auto;
        text-align:center;
        padding-top: 30px;
    }
    
    #buttons
    {
        width: 480px;
        margin: auto;
        text-align: center;
        padding-top:10px;
    }
    
    #if_cookie
    {
        width: 480px;
        margin: auto;
        text-align: center;
        font-size:18px;
        padding-top: 20px;
    }

</style>

<script type="text/javascript">

var navn, inntastetNavn, splitTabell, minCookie;
    if(document.cookie)
    {
        skrivUtNavn();
    }
    else
    {
        inntastetNavn = window.prompt("Tast inn ditt navn");
        document.cookie = "navn=" + escape(inntastetNavn);
        skrivUtNavn();
    }

function skrivUtNavn()
    {
//        document.write("<p>Velkommen " + hentNavn() + "</p>");
//        document.write("<a href = 'javascript:slettCookie('navn')'>" + "</a>" + navn + ", you've already made a cookie, please give it away, by clicking on the 'give away' button, to //make a new one!" );
        if(document.cookie)
        {
            document.write(if_cookie).innerHTML = "Hi" + "inntastetNavn" + ", you've already made a cookie, please give it away, by clicking on the 'give away' button, to make a new one!";
        }//Merk måten å lage en egendefinert anchor som leder til funksjon
    }
function hentNavn()
    {
        minCookie = unescape(document.cookie);
        splitTabell = minCookie.split("=");    
        navn = splitTabell[1];
        return navn;
    }

function slettCookie()
    {
        document.cookie = "navn=null; expires=Mon, 01-Jan-00 00:00:00 GMT";*
        location.reload();
    }//*Her settes datoen for når cookies skal slettes: Viktig!!

</script>

</head>
<body>
<!--function createCookie(name,value,days) -->

<div id="main">
    <div id="main_header">
        <h1>Do you want a cookie?</h1>
    </div>
    <div id="info">
        To make a cookie, write your name and click "create cookie"
    </div>
    <div id="text_box">
        <input type="text" value="Type your name here" />
    </div>
    <div id="buttons">
        <input type="button" value="create cookie" onclick="createCookie()" /><input type="button" value="Give away your cookie" onclick="slettCookie('navn')" />
    </div>
    <div id="if_cookie">
    </div>
</div>

</body>
</html>

Edited by Jaan, 20 April 2010 - 03:05 AM.
Please use code tags when you are posting your codes!