|
Post by AnyKey on Apr 4, 2005 21:52:00 GMT -5
Have you seen some of the GIFs that Ben Ryves has put together? THOSE are so cool! His head falls off and he screws it back on!!!!!
|
|
|
Post by Pure on Apr 6, 2005 15:22:54 GMT -5
they're funny...
|
|
|
Post by bfr on Jun 19, 2005 20:06:06 GMT -5
BACK ON TOPIC! Here is a short tutorial about the BASICS of javascript. This is meant for somebody who knows HTML and wants to boost it with javascript. You insert the javascript code in your HTML document, either in the head or the body. A javascript code is started with the tag: <script> and is ended with: </script> You may also add more detail to the tag, saying stuff such as: <script language="Javascript"> or <script type="text/javascript"> Whatever way you choose to begin your code, it always ends with: </script> . CommentsYou should know about comments because they are part of HTML. A comment that is one line is made by using // for example, //The number of times "Hi" is displayed. Comments are usually used to guide the user through or they sometimes include other critical info. Multi-line comments use: /*VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY LONG COMMENT*/ As you can see, they begin with /* and end with */. Semi-ColonsYOu should put semi-colons after commmands and stuff. ;D In additionYou may put <!-- after where it says <script> and you may put //--> before it says </script> if users use an older browser. Simple Stuff (and your first code)Alerts: To make a pop-up window that is an alert, just type: alert('TEXT') To make a "confirm" pop-up window, type: confirm('TEXT') Confirm is used to say OK. Prompt: prompt('Question or whatever','Sample anwer') Prompt is usualy for asking questions. ALthough you don't have to include a sample answer, it is usually better because if you don't, it says "undefined". Variables: To say what a variable equals, say: var VARNAME=NUMERICAL VALUE It may also be a string, in which it would say var VARIABLENAME="String" TO compare variables, use two equal signs like this: VARIABLE1==VARIABLE2 If-then statements: Syntax: if( condition){stuff if condition is true} There is also an else thing, but that might be too advanced... Summary: Javascript is a fun language and all, but it can be turned off. Use it to boost your HTML!
|
|
|
Post by Vladik on Jun 19, 2005 21:12:48 GMT -5
Yes. It is.
|
|
|
Post by bfr on Jul 5, 2005 11:02:10 GMT -5
There should be a PHP thread. PHP ROCKS! Javascript does do except it can be turned off....
Regular Expressions in Javascript make javascript so much cooler.........
|
|
|
Post by AnyKey on Jul 5, 2005 16:07:43 GMT -5
PHP is okay... I prefer Python for CGI scripting (I told you it did everything!). Coming soon: some cool cgi scripts on my site (as soon as I find a place to host them)
|
|
|
Post by bfr on Jul 6, 2005 10:04:43 GMT -5
Cool! Python is OK...I'm just not very good at it although I could use it.
|
|
|
Post by AnyKey on Jul 6, 2005 10:18:38 GMT -5
I think I'll post the CGI script code in the Python section. It's pretty much debugged (I think), but it'll still go through a couple of revisions once I get it working.
|
|
|
Post by bfr on Jul 7, 2005 8:57:28 GMT -5
Javascript Basics Tutorial Part 2
Functions
Intro:
Functions, just as they are called, are functions that can do stuff. They are groups of code that can be called out.
Basic Syntax:
function MyOwnFunction(){ code here }
Calling a Function:
To call a function, you would just say it's name with a semi-colon after it. For example, if I had the following in my javascript code:
<script> function asking(){ var question=prompt("Do you like milk?","Yes"); var answer="Yes"; if(answer=question){ alert("I like milk too"); }}
I would call (run) the function by having:
asking();
later in the code...
Another way to call it is too have it run when the body is fully loaded. To do so, you would type in:
<body onload="asking()">
A more advanced way to call a function is:
javascript:question()
You are probably going to only use the above method in a few cases, such as:
document.links[2].href="javascript:asking()"
It is basically the same as the first method except that you need the javascript: thing to run it in certain cases.
Additional Function Info:
Have you been wondering why after the function's name there is:
()
It is there for a reason. You may put a message or something like that in there. Here is an example:
function functname(message){ var qstn=prompt(message); }
functname("What is your favorite food");
Functions can also be used to save time, for example if the above section of code was put into use and you added some if-then statements to ask different questions but with the same function.
<script type="text/javascript"> <!--
function cool(text){ document.write(text); }
//--> </script>
<input type="button" name="buttonname1" onclick="cool('This is the first button');" /> <input type="button" name="buttonname2" onclick="cool('This is the second button');" />
That is used to save time and can be handy. It writes:
This is the first button
If you click the first button and writes:
This is the second button
If you click on the second button, all using the same function.
|
|
|
Post by Vladik on Jul 7, 2005 20:33:26 GMT -5
Yeah, I prefer using the javascript:whatever() because you could do some thing like
Got Milk?<br>Take the <a href=javascript:whatever()>Ultimate Milk Challenge!</a>
|
|
|
Post by bfr on Jul 8, 2005 9:33:51 GMT -5
But in some cases the normal way is better. For example:
<script> function abc(text){ alert(text); }
var qst=prompt("What do you want to be displayed?",""); abc(qst); </script>
|
|
|
Post by Vladik on Jul 8, 2005 21:49:22 GMT -5
Yeah, it's the way to do it in scripts.
|
|
|
Post by bfr on Jul 9, 2005 11:56:28 GMT -5
You can use javascript:functionname() or whatever in scripts to. Check the "Confirm Logout" code, by Peter I think. EDIT BY ADMIN: Here is a tutorial that I'd going to try to submit to the SolidSnake Designs website: Start of tutorial: getAttribute(), setAttribute(), and removeAttribute()
getAttribute()getAttribute() returns an attribute's value. It can be very useful and is really easy to learn. Here's the syntax: getAttribute( attribute) Here is an example for a document that had a table with a width of 300 and an id of "myTable": <script type="text/javascript"> var theTablesWidth =
document.getElementById("myTable").getAttribute("width"); </script>
The example above would make the variable theTablesWidth be equal to 300 because the table's width was 300. setAttribute()setAttribute() changes an attributes value by giving it a new one. It is extremely userful. Here's the syntax: setAttribute( attribute, theNewValue) Here is an example for a document that had a table with a width of 300 and an id of "myTable" (the same situation as before) >> <script type="text/javascript"> document.getElementById("myTable").setAttribute("width","200"); </script>
The above example would change the table's width to 200. Here is another example for lets say I had a hyperlink with an id of "myLink" that linked to http://ssdesigns.proboards17.com: <script type="text/javascript"> document.getElementById("myLink").setAttribute("href","http://www.solid
snakedesigns.com"); </script>
The above script would make the link that used to go to ssdesigns.proboards17.com now go to www.solidsnakedesigns.com. removeAttribute()removeAttribute() removes an attribute. It may be useful if you want something to change to the default setting. Here's the syntax: removeAttribute(" Attribute") Here is an example for a document that had a table with a and an id of "myTable" (the same situation as before) >> <script type="text/javascript"> document.getElementById("myTable").removeAttribute("width"); </script>
The above example would remove the table's width attribute, setting it to the default width. ConclusionCombining the powers of getAttribute(), setAttribute(,), removeAttribute() can give you pretty complex websites. Maybe you use getAttribute() to get a table's width and store it into a variable, and then use setAttribute() to increase the table's width by 100 pixels. Hope you all enjoyed the tutorial and happy coding! End of tutorial. Please post any comments or suggestions. EDIT #2 BY ADMIN: Everybody hates javascript? Or is it my tutorial that scared everyone away? I submitted it btw. EDIT #3 BY ADMIN: Also, Anykey, instead of using Python for cgi, why don't you try a different types of server-side scripting, such as php or asp? Many people use those languages.
|
|
|
Post by Vladik on Oct 23, 2005 13:21:19 GMT -5
USE THE FUCKING EDIT FUNCTION!!! FOUR POSTS IN A ROW!
|
|
|
Post by bfr on Oct 23, 2005 16:27:12 GMT -5
See what I mean? Half of the time, you don't contribute something that is useful and/or on-topic.
btw there are many other ways to do the same thing as removeAttribute(), getAttribute(), and setAttribute() .
|
|
|
Post by Vladik on Oct 23, 2005 18:14:30 GMT -5
I am the administrator, and it is my job to administrate, not to contribute! I will contribute when I feel like contributing, but at the other times, I will be making sure that this forum runs smoothly.
|
|
|
Post by bfr on Nov 3, 2005 19:56:04 GMT -5
The jpg is generated by a php. And JavaScript can do the same as PHP... Actually, they are really different and are meant for different perposes.
|
|