Jump to content

Search the Community

Showing results for tags 'javascript'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • RuneLocus
    • News & Announcements
    • Information Booth
    • Website Support
    • Introductions
    • Chat
    • Forum Games
  • RuneScape Development
    • RSPS General
    • RuneScape Private Server (RS2)
    • RuneScape Private Server (503+)
    • RuneScape Private Server (EoC 742+)
  • Other
    • Digital Art
    • Gaming
    • Webdevelopment
    • Computers
  • Marketplace
    • RuneScape Market
    • RSPS Market
    • Others Market
    • Freelance Middleman Services
  • Super Secret Club's Topics

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 12 results

  1. Now I have this [CODE] var d = new Date(); var Day = d.getUTCDate(); var Hours = d.getUTCHours(); var month=new Array(12); month[0]="January"; month[1]="February"; month[2]="March"; month[3]="April"; month[4]="May"; month[5]="June"; month[6]="July"; month[7]="August"; month[8]="September"; month[9]="October"; month[10]="November"; month[11]="December"; var Month = month[d.getUTCMonth()]; var Minutes = d.getUTCMinutes(); if (Minutes < 11){ Minutes = "0"+Minutes; } document.write("Game time : " + Day + "/" +Month+ " " +Hours+": "+Minutes+" .<br/>"); [/CODE] It will print as : Game time : 29/January 16: 18 . (24 hour) I want instead : Game time : 29/January 6: 18 . (12 hours) I am new to JS, so please explain like I am 5
  2. Take the following code into consideration: [HTML] <center><button onclick="myFunction()">Click here to enter name.</button> <p id="NAME"></p> <script> function myFunction() { var x; var person=prompt("Please enter your name","enter name here"); if (person!=null) { x="Hello " + person + "! Click the button below to continue!"; document.getElementById("NAME").innerHTML=x; } } </script> [/HTML] Now if I wanted to use that persons name in a sentence on a different page, how would I go about doing that? Thanks in advanced, i'm working on an html based rpg game to try and learn more about this language, your help is much appreciated :) Edit: also, how would I go about starting the js without pressing a button?
  3. I thought i would share some of my knowledge on Javascript with all of you guys. Note: i created this back in 2011-2012. This is the first time i'm sharing it with anyone. [COLOR=#ff0000][SIZE=4]PROGRAMMING WITH JAVA SCRIPT [/SIZE][/COLOR] INSTEAD OF OTHER GUIDES WHERE ALL YOU ARE GIVEN IS CODES, I ACTUALLY EXPLAIN WHAT THE HELL YOU ARE CODING. PLEASE TAKE THE TIME TO READ EVERYTHING. THAT'S THE ONLY WAY YOU WILL TRULY UNDERSTAND JAVA SCRIPT. [COLOR=#0000ff][SIZE=3]CHAPTER 1 [/SIZE][/COLOR] Server Side • Server side scripts reside on the server (main computer) while client side scripts reside on a user PC • Storing all programs on the server allows multiple users simultaneous access but poses potential connection and performance issues. Client Side • While client side scripts are not as powerful and will never fully replace server side scripts, they do offer a convenient alternative for performing some of the simple, low-key tasks locally. Why JavaScript? • HTML allows developers to create static web pages, the information and look of the page does not change. • JavaScript allows you to create pages where content and layout can be modified using special code built into the page. [COLOR=#ff0000][SIZE=3]Java vs. JavaScript [/SIZE][/COLOR] [COLOR="#800080"]I included this for people who have no knowledge of Java or Javascript and would like to know the difference.[/COLOR] Java • Code is powerful but complex • A special app (JDK) required • Programs must be saved and compiles separately • Used for complex tasks JavaScript • Code is easy to learn and to use • No additional software is needed • Code can be added directly anywhere in the HTML text editor • Used for quick, simple tasks [COLOR=#ff0000][SIZE=3]Code Example[/SIZE][/COLOR] [CODE] <script> document.write(“Today is 12/20/2011 <BR>”) document.write(“Only 10 days until the New Year!”) </script> [/CODE] [COLOR=#ff0000][SIZE=3] Variables[/SIZE][/COLOR] • A Variable is a verbal representation of information that can be substituted for information. • Before you can use a variable can be used in the code it has to be created using a variable declaration. Variable Types • Numeric variables- any number in standard or scientific notification • String Variables – text (Must be in quotes) • Boolean variables- TRUE/FALSE. Used when you want the program to act depending on condition • Null Variables- a variable without an assigned value. [COLOR=#ff0000][SIZE=3]Naming Rules[/SIZE][/COLOR] • The first character must be a letter or an underscore • The remaining characters must be letters, numbers or underscores • Names cannot contain spaces • JavaScript code items cannot be used as variable names. [COLOR=#ff0000][SIZE=3]Variable Example[/SIZE][/COLOR] --------------------------------------- var month ="March"; document.write(“School starts in” + Month); OR month = “March”; document.write(“School starts in” + Month); --------------------------------------- Both of the codes above will yield the same result. Which is: [COLOR="#FF0000"]School starts in March[/COLOR] [COLOR=#ff0000][SIZE=3]Expressions and Operators[/SIZE][/COLOR] • A JavaScript expression is a command that is used for assigning values to defined variables. • A JavaScript operator is an element that can be used within an expression to perform and action, such as adding or combining multiple elements.. • The most commonly used operator is the equal sign (=) that will assign a value to the preceding variable. • Another example of an operator is the plus sign (+) used for combining multiple elements. [COLOR=#ff0000][SIZE=3]Assignment Operators [/SIZE][/COLOR]• In JS, values are assigned to variables using assignment operators. • An example is the equal sign (=) [COLOR=#ff0000][SIZE=3]Functions[/SIZE][/COLOR] • A function is a series of commands that can be executed by your program to calculate a value or perform an action [COLOR=#ff0000][SIZE=3]Benefits of Funtions[/SIZE][/COLOR] • Complex programming tasks can be broken down into simpler steps • Code does not have to be duplicated within a program • Code can be reused multiple times by a placing a simple function call anywhere is the program [COLOR=#ff0000][SIZE=3]Declaration [/SIZE][/COLOR]• A function has to be created using a function declaration like the one below --------------------------------------- Function Name(Function Variables) { Function Commands; } --------------------------------------- [COLOR=#ff0000][SIZE=3]Three major parts of a function:[/SIZE][/COLOR] Function Name= identifies each function Parameters= Values needed by the function to produce the expected result Commands= Actions that will be executed when the function runs. Calling a function Whenever you need to use the function you created you must insert this piece of code: --------------------------------------- FunctionName(Variables); --------------------------------------- (Replace "FuntionName" with the name you created for your function. Replace "Variables" with whatever variables you need to use) [COLOR=#0000ff][SIZE=3]End of Chapter 1 [/SIZE][/COLOR] [size=4][color=#0000ff]Chapter 2[/color] [/size] [SIZE=3][color=red]Arrays[/color][/size] • In a typical computer program, data cannot be stored without the use of a database such as Access, Oracle, DB2 etc. • Some of the program data, however, can be stored on a temporary basis by using data structures known as arrays. • An array is a systematic arrangement of objects, usually is a rows and columns. Like a table./ single column table with a name assigned to it [size=3][color=red]Array Example[/color][/size] [size=3]--------------------------------------------[/size] Var ArrayName= new Array(size); ArrayName[index]= value; ArrayName[index2]=value 2 ; [size=3]--------------------------------------------[/size] • The size is expressed as the number of elements that the array is going to contain. • You can leave the size blank and have JavaScript automatically increase the array size as new elements are added. • Index represents the row number [SIZE=3][COLOR=#0000ff]Coming up:[/COLOR] [COLOR=#0000ff][SIZE=2] Loops Objects/Events Prompting user for input Creating calculated fields Validating user input[/SIZE][/COLOR][/SIZE]
  4. If you didn't believe me, it is possible (and very easy) to integrate JavaScript into a private server as a scripting language for content: [url]https://github.com/Whackatre/RuneSourceJS[/url] Although I definitely prefer Ruby. :p Thoughts? Rate/hate/flame/thank/WTF/LOL/give feedback/ all appreciated.
  5. Hi, this is my second tutorial, it will be about using a function to call two or more other functions, it can be used simply to keep your code in smaller pieces so you don't have big heaps of code, and it can be a lot easier to spot a bug. So let's get started. [code]<script type="text/javascript"> function numberOne(){ document.write("This is the function that will appear first."); } function numberTwo(){ document.write("This is the function that will appear second."; alert("end"); } /* as of right now this is doing nothing, we have made two functions but we are not calling them, so let's do that.*/ function start(){ numberOne(); numberTwo(); } start(); </script>[/code] What that is doing is calling both the first and second method as one, in a single method. I put alert end in numberTwo because it is the last method to be called, in which the script will then end. If you wanted to, you could call more than that, you could even make 5 methods but on call the third and fifth one. You can also call a function in the first function, then call the first function in the second one, then call them both in a third; creating a infinite loop.
  6. Hi, this is my 3rd JavaScript tutorial and it will be about different types of variables There are two types of variables, a global and a local variable. A global variable a a variable created anywhere in your script, not in a function. A local variable is a variable that is created [b]inside[/b] of a function. [code]<html> <head> </head> <body> <script type="text/javascript"> var g = "bacon tester"; function iSean() { alert("Hello there"); } function iCoke(){ alert("Bye bye now"); } function iStart(){ var h = "ham tester"; iSean(); iVar(); document.write(h); document.write(g); } iStart(); document.write(h); </script> </body> </html>[/code] So, from the script above can see that 'G' is a global variable, and 'H' is a local variable. There are certain rules that apply to these variables though that I will explain in this tutorial. A global variable is one that you can call from both outside, and inside a function. So in the script we can see that Variable G is being called from inside of function iStart. If you were to run this on Chrome, or any other browser it would should you it is being used by printing out on the screen "bacon tester." but now let's say we wanted to use variable H that we created in iStart and try to write it on the screen by calling it [b]outside[/b] of it's function, nothing will happen. So what I'm getting at is, global can be used anywhere at all times, local cannot. It's like the function is saying "no, i created this so you cannot have it!" and will not allow anything to happen to it. That's basically all you need to know from this tutorial, is how to use those two types properly. It's pretty easy to remember to, global = world wide, local = near by. Don't pay much attention to the alerts being used in the first two functions, if you read my second tutorial you should be able to understand what's going on there and why I made a function just to call them.
  7. Hi, I will be showing you how to handle two types of arrays in Javascript, that will bring the same results. Way #1: [code]<script type="text/javascript"> var things=new Array("lasers","swords","apples"); alert(things[2]); <script>[/code] Now, that would bring the user a popup box saying "apples." Most would think it would bring up swords, because it is the second thing in the array. However, the computer does not read it like humans to. It reads like 0,1,2,3, etc. So, lasers would be 0, and so on. Way #2. [code]<script type="text/javascript"> var things=new Array(); things[0]="lasers" things[1]="swords" things[2]="apples" alert(things[2]); things[3]="grapes" alert(things[3]); <script>[/code] This is the way I prefer doing it, because it is a lot more clear on which variable is which. It's a personal preference thing though, really. Also; the only reason I added the alert in this tutorial without introducing it, is because I wanted to give the array a simple function. all the alert does is bring a pop-up to the screen. Elements- [code]<script type="text/javascript"> var things=new Array(); things[0]="lasers" things[1]="swords" things[2]="apples" alert(things[2]); things[3]="grapes" alert(things[3]); <script>[/code] As you can see, I have added something new to our array that is not under it. It appears after our first alert; but javascript reads from top to bottom. So, if you were to do this it would first alert apples, then after you click okay it will alert grapes. This is important to remeber that you do not have to add things right under the array, just keep the naming the same, It can also be useful while scripting. Inb4 everyone calls me an idiot: I JUST started learning javascript today lol
  8. [CENTER][FONT=Impact][SIZE=5]Small SNIPPET Help![/SIZE][/FONT] [b] What this is for?: Gambling system, 55x2 Dicing. What do I need help with: Adding multiple gaming item choices (All phats, santa hat, all masks, and 750m GP choice) Class file?: DialogueHandler.java THANK YOU SO MUCH! -- It would also be nice if you could include a little example for setting up an NPCDialogue with sendOption2(" "); in it, I want to use this instead of 'click continue' to accept. Code:[/center][/b] [code] case 608://dicing npc 50percentelf sendNpcChat2("Click to join dicing match!", "You need a rare or 750m to play", c.talkingNpc, "dicer"); c.nextChat = 421; break; case 421://normal win c.sendMessage("You don't have anything in your inventory that the dicer likes.."); c.nextChat = 0; if (c.getItems().playerHasItem(1050, 1)) { sendNpcChat2("!!!", "DICE ME THAT SANTA HAT!!", c.talkingNpc, "dicer"); c.nextChat = 609; } break; case 609://npc dicing extreme int random2 = Misc.random(100); int ItemHas = { if (random2 >= 55)//begin winning { sendNpcChat1("You win!", c.talkingNpc, "dicer"); c.nextChat = 0; c.sendMessage("@[email protected] rolled more than or equal to 55! , you win!"); c.sendMessage("The dicer gives you a noted Santa Hat!"); c.getItems().addItem(1051, 1); } if(random2 <= 54) //begin lose{ { sendNpcChat1("You lose!", c.talkingNpc, "dicer"); c.nextChat = 0; c.sendMessage("@[email protected] rolled less than or equal to 54! , you lose!"); c.sendMessage("The dicer takes your Santa Hat!"); c.getItems().deleteItem(1050, 1); } break; }[/code] KEY: [[COLOR="#FF0000"]#[/COLOR]] ACTION [[COLOR="#00FF00"]#[/COLOR]] CONTINUE (ACCEPT) [[COLOR="#FF8C00"]#[/COLOR]] NPCTALKING I would like to add more options.. Right now its set to this sequence; [CODE][COLOR="#FF0000"]talktoNPC[/COLOR] > [color="#FF8C00"]"Click to Join Dice Match!"[/COLOR] [COLOR="#00FF00"]'Click here to Continue'[/COLOR] > [color="#FF0000"]AUTODETECTSitem[/COLOR] 'Santa Hat' [color="#FF8C00"]"!!!", "DICE ME YOUR SANTA HAT"[/COLOR] [COLOR="#00FF00"]'Click here to Continue'[/COLOR] > [COLOR="#FF0000"]YOU WIN : YOU LOSE[/COLOR] *GAINS OR LOSES THAT ITEM*[/CODE]
  9. okay so i have this chunk of php, it's being used, but the showUser($id) isn't going through [PHP] if(isset($_POST['submit2'])) { $errors = array(); $searchTerm = mysql_real_escape_string(trim($_POST['editsearch'])); $sql = "select * from item where name like '%$searchTerm%' order by name"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $id = $row['id']; } showUser($id); exit; }[/PHP] i originally had a die("") right before the showuser to output the id it's sending, and it works fine any idea why it's not working? showuser -> [HTML]function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getitem.php?q="+str,true); xmlhttp.send(); }[/HTML] showuser method works just fine, it's just the way it's being called, it works fine when i use it as a drop down menu function [HTML]<form> <select name="users" onchange="showUser(this.value)"> <option value="">Select a person:</option> <option value="1">Option 1</option> ...[/HTML] that works fine, but it's not working through the PHP calling of it ALSO, the way of grabbing the $id seems a bit long, whats a simpler/more efficient method of grabbing $id from the database?
  10. Can anyone make a javascript code that makes a div lower it's opacity until it reaches 0 and show's another div. except, rising the opacity to show the div? like click button1, (lowering opacity from 100 to 0 for Div1, then rising opacity of Div2 from 0 to 100) and click button2, (lowering opacity from 100 to 0 for Div2, then rising opacity of Div1 from 0 to 100) possible? Currently I have a javascript running for the buttons that it will automatically hide and show the other div. without any effects.
  11. Load up any website you would like to play around with WARNING: This doesn't save Goodluck!
  12. Use this to stop people leeching stuff..... Copy this into your <head> tag <td><script language=JavaScript> <!-- //V2.5 No Right Click //Created by Shaun var message="You cannot click here."; /////////////////////////////////// function clickIE() { if (document.all) { (message);return false; } } function clickNS(e) { if (document.layers||(document.getElementById&&!document.all)) { if (e.which==2||e.which==3) { (message);return false; } } } if (document.layers) { document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS; } else{document.onmouseup=clickNS;document.oncontextmenu=clickIE; } document.oncontextmenu=new Function("return false") // --> </script></td>
×