Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Alerts, Buttons , Popups


1 reply to this topic

#1 mranimationist

    Newbie [Level 1]

  • Kontributors
  • Pip
  • 15 posts

Posted 08 May 2010 - 04:33 PM

Hi, All I hope yuo've enjoyed my last few posts and topics this may well be my last programming post for a week or two.

Okay I am going to be talking about how to get a website that has javascript in it :)

just copy the below If you do not understand it comment below
<html>
<head>
<title>
My first javascript ~ Wooo!</title>
</head>

<body>

<script type="text/javascript">

document.write("Hello World");

</script>

</body>
</html> 
as you can see it goes along side HTML

So thats the text part done

Now on to the pro stuff.

This is for an alert box
<html>
<head>
<script type="text/javascript">
function show_alert()
{
alert("Hello! I am an alert box!");
}
</script>
</head>
<body>

<input type="button" onclick="show_alert()" value="Show alert box" />

</body>
</html>

Now onto selection popup boxes
<html>
<head>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Press a button");
if (r==true)
  {
  alert("You pressed OK!");
  }
else
  {
  alert("You pressed Cancel!");
  }
}
</script>
</head>
<body>

<input type="button" onclick="show_confirm()" value="Show confirm box" />

</body>
</html>
Prompt Box
<html>
<head>
<script type="text/javascript">
function show_prompt()
{
var name=prompt("Please enter your name","Name");
if (name!=null && name!="")
  {
  document.write("Hello " + name + "! How are you today?");
  }
}
</script>
</head>
<body>

<input type="button" onclick="show_prompt()" value="Show prompt box" />

</body>
</html>
In this tut i am not going to explain what they meen because I do not have the time

Notice from rvalkass:

Please make sure you use the correct BBCodes in your posts.


#2 TheDarkHacker

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 251 posts
  • Gender:Male
  • Location:somewhere where arent others
  • myCENT:1.16

Posted 08 May 2010 - 08:43 PM

It is nice you tried to do something,but here is what you should do.

If you don't have time for explaining,why you are writing tutorial? When you will finish with the tutorial,post it and add some pictures,so people will understand it faster.

This things aren't so simple for beginners,you should describe more and more,for events,function args,function returns,etc.

By the way,i think adding scripts to the head is better , things that are not visible should(not must) be added to head part of the website.




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users