Jstyle Posted January 3, 2006 Share Posted January 3, 2006 Link to comment Share on other sites More sharing options...
Lews_Therin Posted January 3, 2006 Share Posted January 3, 2006 This is Javascript, which is quite different from Java. I advise changing the title to get help. Link to comment Share on other sites More sharing options...
Aldeon Posted January 4, 2006 Share Posted January 4, 2006 Yeah difference in Java and JavaScript Java - client side programming language created by SUN microsystems Javascript - Dynamic web scripting language created by Netscape All that is doing is just incrementing the variable, number by 1. You just have a "loose" variable it's not being used at all try adding under it document.write(number); //its been a while since i have done java script It's been awhile but from the looks of it everytime the page loads there is no variable called number. It then creates it and when it reaches the line it refers to the function and increments (raise) by 1. you could also say number=number+1 Also the is not a valid HTML tag (at least i dont think so) Or actually it is the more i think about it such as onMouseOver="" My way would be use php. I dont know if you can read/write text files with javascript....never was bothered with it but create a text file called counterA.txt and in it have 1 line and on that type 0 (DO NOT PRESS SPACE BAR OR ENTER/RETURN) Now save it Now when the page is visited have the script call on the file and open it up for r/w and save whats in the txt file to a variable (lets say a1 Now it will most likely be a string (does javascript have int and strings...i forgot) So parse it into a integer(int) if needed and store that to a variable (lets say b2) Now increment the variable that contains the integer value by 1 since the use visited the page (b2++) Parse it back into string so it can be written into the txt file use a function to delete everything in the file Now write the variable b2 to the file Save the file so it can be called upon again and not lose the count Now use the document.write(b2); And it will write the value of it which is the number in the file incremented by one or the number of visits You can find the functions and how to do that on the net. I just outlined how it should work Link to comment Share on other sites More sharing options...
Mercifull Posted January 4, 2006 Share Posted January 4, 2006 I wont go into detail about java/javascript/problems with your code because its pointless. The main problem lies in that you dont have FTP access with your invisioncrapfree so cant upload any files for use with this counter. Now i dont know to what extent you can modify the template files but you will probably only be able to get a counter working with a remote script. try searching google for a remote counter service Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12 Link to comment Share on other sites More sharing options...
Aldeon Posted January 4, 2006 Share Posted January 4, 2006 I'll write the code for you i havent done javascript in awhile but just let me get a reference table. I will give you bits of codes and tell you where to place them along with setup instructions for the txt file. If you want it as a picture instead of text for a counter what you need to do is draw the frame and bg of the counter and the numbers 0-9. Then seperate your varaible into seperate digits stored in an array use a loop to loop through all the values in your digit array. While using if statements (or switch if javascript supports them its been awhile guys...so idk) to decide which image to use that matches the number store the img urls to another array put the img of the frame on it then use a loop to loop through the arrays and draw it using absolulute postioning. also use a counting variable to keep track of what digit your own so you can use that to move the position of the image. theres how to make a image counter....i cant be bothered with al that so when i get a chance ill write a text counter for you....although im sure you can find a source code already made on the net Link to comment Share on other sites More sharing options...
Hannibal Posted January 5, 2006 Share Posted January 5, 2006 I'll write the code for you i havent done javascript in awhile but just let me get a reference table. I will give you bits of codes and tell you where to place them along with setup instructions for the txt file. If you want it as a picture instead of text for a counter what you need to do is draw the frame and bg of the counter and the numbers 0-9. Then seperate your varaible into seperate digits stored in an array use a loop to loop through all the values in your digit array. While using if statements (or switch if javascript supports them its been awhile guys...so idk) to decide which image to use that matches the number store the img urls to another array put the img of the frame on it then use a loop to loop through the arrays and draw it using absolulute postioning. also use a counting variable to keep track of what digit your own so you can use that to move the position of the image. theres how to make a image counter....i cant be bothered with al that so when i get a chance ill write a text counter for you....although im sure you can find a source code already made on the net Aldeon, please don't say you'll do X for a user if it isn't even possible (and you clearly don't know what you're talking about). JavaScript is client side, so it cannot write a file to the server (nor can it write files to the client machine, as that would be a security issue...). Hence you can't increment the counter from javascript. Some mistakes in everything you said on this topic (I really can't be bothered looking it all through, but whatever) 1. 'then make it back into a string' - javascript doesn't typically typecast variables. It 'magically' converts between them as necessary. 2. He did define the variable (var number = 1;) 3. JS supports switch statements fine. 4. number++ is a lot cleaner than number = number + 1, and will execute much faster in most (good) js evaluators 5. is not a valid tag, nor is . onmouseover and onload are valid attributes for tags though, so in this case he probably meant: 6. document.write() is BAD and it SHOULD NOT BE USED. Use DOM methods instead, eg: document.lastChild.appendChild(document.createElement("p").appendChild(document.createTextNode("Some text"))) Link to comment Share on other sites More sharing options...
taquar Posted January 5, 2006 Share Posted January 5, 2006 this isnt a valid html tag. it must be placed here: inside the body tag. Finally retired from RS. It's been a good 4 or 5 years. Link to comment Share on other sites More sharing options...
7up407 Posted January 5, 2006 Share Posted January 5, 2006 Ok first off invision power boards are run off of php not phpbb php a type of coding, i'm almost posotive that java script will not work off of php forums, and also the fact you don't have FTP access witch is a website that you can go to your power tools and change the codes and download mods. Link to comment Share on other sites More sharing options...
Aldeon Posted January 6, 2006 Share Posted January 6, 2006 I'll write the code for you i havent done javascript in awhile but just let me get a reference table. I will give you bits of codes and tell you where to place them along with setup instructions for the txt file. If you want it as a picture instead of text for a counter what you need to do is draw the frame and bg of the counter and the numbers 0-9. Then seperate your varaible into seperate digits stored in an array use a loop to loop through all the values in your digit array. While using if statements (or switch if javascript supports them its been awhile guys...so idk) to decide which image to use that matches the number store the img urls to another array put the img of the frame on it then use a loop to loop through the arrays and draw it using absolulute postioning. also use a counting variable to keep track of what digit your own so you can use that to move the position of the image. theres how to make a image counter....i cant be bothered with al that so when i get a chance ill write a text counter for you....although im sure you can find a source code already made on the net Aldeon, please don't say you'll do X for a user if it isn't even possible (and you clearly don't know what you're talking about). JavaScript is client side, so it cannot write a file to the server (nor can it write files to the client machine, as that would be a security issue...). Hence you can't increment the counter from javascript. Some mistakes in everything you said on this topic (I really can't be bothered looking it all through, but whatever) 1. 'then make it back into a string' - javascript doesn't typically typecast variables. It 'magically' converts between them as necessary. 2. He did define the variable (var number = 1;) 3. JS supports switch statements fine. 4. number++ is a lot cleaner than number = number + 1, and will execute much faster in most (good) js evaluators 5. is not a valid tag, nor is . onmouseover and onload are valid attributes for tags though, so in this case he probably meant: 6. document.write() is BAD and it SHOULD NOT BE USED. Use DOM methods instead, eg: document.lastChild.appendChild(document.createElement("p").appendChild(document.createTextNode("Some text"))) I mentioned i havent used Javascript in awhile (almost 4 years to be mor exact) so i forgotten lots of things and barely remeber a thing about it The web scripts i do now are server side and i rarely do web scripts anymore. I hardly do any coding at all anymore thats what i cmae up with in my own kind weird version of pseudo. I think i said i didnt know if javascript could do all that the only thing i remeber from it is setting variables and the document.write(); function Link to comment Share on other sites More sharing options...
joeyjo0 Posted January 13, 2006 Share Posted January 13, 2006 about the function addnumber() command: what function does it execute?! Link to comment Share on other sites More sharing options...
Antony Posted January 13, 2006 Share Posted January 13, 2006 about the function addnumber() command: what function does it execute?! Obviously addnumber. I'm assuming I am missunderstanding you though. :::Antony 7::: Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now