JavaScript - Just Some Quick Help Please
ok so im making a runescape private server and i have all the files and i compile and i only get 1 error.
witch is the following. http://imageshack.us/content_round.p...upload&newlp=1 can anyone help me out pleasE? Similar TutorialsHey guys, I am very VERY new to javascript and while trying to do some simple validating I got stuck and am in a complete loss. Heres my code: Code: <html> <head> <title>Tareas | Numero 4</title> <link rel="stylesheet" type="text/css" href="style.css" /> <script language="javascript" type="text/javascript"> function verify() { total = "Te faltaron los siguientes Campos por llenar: \n"; nombre = document.getElementById("txtnombre"); if (nombre.value == "") { total = total + "\nnombre"; } apellido = document.getElementById("txtapellido"); if (apellido.value == "") { total = total + "\napellido"; } if (total == "Te faltaron los siguientes Campos por llenar: \n") { return true; { else { alert(total); return false; } } </script> </head> <body> <center><h3>Formulario de registracion</h3></center> <div id="formulario_overall"> <form method="post" onsubmit="return verify();" action="/"> <div id="formulario_left"> Nomb <br /> <br /> Apellido: <br /> <br /> Clave: <br /> <br /> Confirmacion de Clave: <br /> <br /> Edad: </br> <br /> <br /> Sexo: </br> <br /> Ciudad: </br> <br /> </div> <div id="formulario_right"> <input type="text" name="nombre" id="txtnombre" /> <br /> <br /> <input type="text" name="apellido" id="txtapellido" /> <br /> <br /> <input type="password" name="p_1" id="p1" /> <br /> <br /> <input type="password" name="p_2" id="p2" /> <br /> <br /> <input type="text" name="age" id="age" /> <br /> <br /> <input type="radio" name="sex" id="sex" /> Femenino<br /> <input type="radio" name="sex" id="sex" /> Masculino<br /> <input type="text" name="city" id="city" /> <br /> <br /> </div> <div id="formulario_bottom"> Terminos De Uso: <textarea rows = "4" cols = "37" readonly="readonly"> Accepto que voy a darle +20 puntos a Daniel Martinez. Accepto que voy a darle +20 puntos a Daniel Martinez. Accepto que voy a darle +20 puntos a Daniel Martinez. Accepto que voy a darle +20 puntos a Daniel Martinez. </textarea><br /> <div><input type="radio" name="terms"> Accepto <input type="radio" name="terms" /> No Accepto</div> <br /> <center><input type="submit" value="Submit" /> <input type="reset" value="Limpiar" /></center> </form> </div> </div> </body> </html> Hope you guys can help me out :/ I just feel like I am doing something totally wrong. Ok, this might sound stupid but I swear, it's about to drive me crazy. how does one check whether or not a javascript "global" variable is undefined that will work with IE? I've tried each variation of code and checked countless forums: Code: if (saved == undefined || saved == null) { alert('saved'); saved = new Array(); } returns no error and nothing happens Code: if (saved == 'undefined') { alert('saved'); saved = new Array(); } -- returns error = saved is null or not an object Code: if (typeof(saved) == undefined) { alert('saved'); saved = new Array(); } returns same as above help me please, I'm confused more then anything. the link is also: http://doodlekins.hcents.com/designer Basically the if statement isn't returning true and nothing on the inside of it is ever happening. Don't even know where to post this as I have never thought about it; I've just made my game have a image upload script in, and a album showing the users images. How could I make have a link saying "Copy Link" that if clicked will copy the picture url to clip board. I've seen places like w3schools use in but not as tuts though. Please this will really help, desplayin the link is ugly EDIT: I've found the following code but I don't understand how I turn it into a link or button. Code: <script> window.clipboardData.setData('text','This has been copied to your clipboard.'); </script> I tried posting this: <button type="button" onclick="JavaScript:alert('Let's assume.....')"> <img src="question.jpg" alt="Click here" /> <br />Click for Answer!</button> and it shows the button with the picture, but I am unable to click it. Can you please help me? Thank you in advance. I know that global variables are properties of the window object... so does that mean that local variables are properties of the function they belong to? And does that mean that functions are methods of the window object and that nested functions are methods of the function they belong to?
Urghh I've always done it this way but it's nagging me. Is there a better way of checking if a value is equal to 1 or 2 or 3 than doing it this way. Code: if(var === Cat || var === Dog || var === Chicken || var === Frog) Not working code ^ lol Cheers guys I am new to java and tried writing the code for practice but it doesn't seem to work <html> <Head> <title>Discount</title> <script language ="Javascript"> <!-- function CalculateBalance(numItems,totPrice,discount) { var balance; balance = (1 - discount)*totPRice; alert ('Your balance is $'+balance +' Thank You.'); document.write("<br>YOu bought "+ numItems+" items for $"+totPrice); document.write("<br>Your balance is $"+ balance+" your discount was"+discount*100+"% Thank you"); } //--> </script> </head> <script language ="Javascript"> <!-- var discount; var numItems = parseInt(prompt('HOw many time did you buy [ >=12 is 20% and >= 6 is 10% discount]',"0")); alert ('You bought '+numItems +' items.'); document.write("You bought "+ numItems+" items."); var totPrice = parseFloat(prompt('The total price that you paid was',"0.0")); if(numItems >= 12) {discount = .2;} else if (numItems >=6) {discount+ .1} else {discount = 0;} CalculateBalance(numItems,totPrice,discount); //--> </script> </html> It only prints to the screen the number of items I bought Hi all, This is a quickie. I'm a JavaScript newbie. I have had a crack programming with it but I need some questions answered to help my understanding. Please tell me the convention that governs the use of "" and '', because so many articles that I am finding in my learning journey are using them interchangeably and it is so confusing. For instance, but not limited to, take the id and value tags of an <input type=... of whatever. Is it best to use '' or "" for the labels you give? What is the convention governing the use of a ; (semicolon) because so many people use one where others do not. I'm under the impression it is an EOL terminator like in Bash, right? So it goes after declaring variables or after something within an if statement perhaps? Thanks QF Hi, I have the below code, but got a problem with it. The problem is, if you click Test 1, then Test 2 you have to click Test 2 twice, this also repeats for Test 3, 4 and 5. It is the same with onclick. I presume the problem is in the javascript code, but not sure where to start. Can anyone help <html> <head> <title>Test JS</title> <script language="javascript"> <!-- var state = 'none'; function showhide(layer_ref) { if (state == 'block') { state = 'none'; } else { state = 'block'; } if (document.all) { //IS IE 4 or 5 (or 6 beta) eval( "document.all." + layer_ref + ".style.display = state"); } if (document.layers) { //IS NETSCAPE 4 or below document.layers[layer_ref].display = state; } if (document.getElementById &&!document.all) { hza = document.getElementById(layer_ref); hza.style.display = state; } } //--> </script> </head> <body> <p><a href="javascript:showhide('sect1');">Test 1</a></p> <div id="sect1" style="display: none;">Test 1 content</div> <br><br><br> <p><a href="javascript:showhide('sect2');">Test 2</a></p> <div id="sect2" style="display: none;">Test 2 content</div> <br><br><br> <p><a href="javascript:showhide('sect3');">Test 3</a></p> <div id="sect3" style="display: none;">Test 3 content</div> <br><br><br> <p><a href="javascript:showhide('sect4');">Test 4</a></p> <div id="sect4" style="display: none;">Test 4 content</div> <br><br><br> <p><a href="javascript:showhide('sect5');">Test 5</a></p> <div id="sect5" style="display: none;">Test 5 content</div> </body> </html> I put the jquery script into my subdirectory. In the header which one is correct: Code: <script type="text/javascript" src="../jquery/jquery.js"></script> or Code: <script src="../jquery/jquery.js"></script> And there is this code: do I put this in the body and enclose it with the <script>tag? Code: $(function(){ // set interval for 5 minutes setInterval(function(){ $.ajax({url: "keep-alive.php"}); }, 300000); }); can I have a function and a variable be the same name in an object for instance Code: function someObject(){ this.canDoSomething;//a boolean variable function canDoSomething(){ //set this.canDoSomething; return this.canDoSomething; } } or will this be a naming conflict? thanks Was wondering if someone could help me quickly, i'm have a strange issue with a slideshow i have built in javascript. The slideshow works fine until you add any other image onto the page like a banner or anything. As soon as you do that when you click next on the slideshow that image or banner with change to the next picture instead of the desired image if that makes any sense... Would appreciate any help, thank you! here is the link to my practice website, so you can see what is going on pretty new to all of this.. http://dpetersen.net46.net/advancedw...l.html?agree=0 I have a twitter widget at this side http://1905.gs/blog on the right sidebar. At the bottom of the widget there is the follow me link. I would like to embed a follow me "button" which I have created the script for: The button script: <a href="https://twitter.com/1905GS" class="twitter-follow-button" data-show-count="false" data-lang="tr">Takip et: @1905GS</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> And here is the current javascript link: http://www.1905.gs/blog/wp-content/p...tter-widget.js How I am trying to make it look like: http://a1202.hizliresim.com/u/d/2nryy.jpg thank you very much for your help, I am working on a site for an online radio station and I want an external player to launch on site visit and to continue playing as the visitors surf my site. I feel I am 95% there as I have the player spawning on launch and checking for popup blockers. If a popup blocker is found the user is prompted to add my domain to their allowed lists so that future visits will launch the player right out of the box. My problem is this. When someone navigates back to the "home" page (where the script is located the external player window reloads and I do not want it to. I have found a couple of sites that say do this and that but I am a 100% novice at javascript and can not figure it out. here is the url of the site I am building http://www.radiotrips.com/czmradio - If you have popup blocker on you should get an alert. If not a small player should launch here is the code that I am using to spawn the external player and check for popup blockers ************** <script language="javascript" type="text/javascript"> function detectPopupBlocker() { var czmTest = window.open("http://www.radiotrips.com/czmradio/player/mini/no_ads.html","Cozumel Radio","width=478,height=260"); if (!czmTest) { alert("We were unable to automatically open the Cozumel Radio Player due to your pop-up blocker... Please add CozumelRadio.net to your allowed sites for your best listening experience"); } else { window.open("http://www.radiotrips.com/czmradio/player/mini/no_ads.html","Cozumel Radio","width=478,height=260"); } } ************** if anyone could add the code that would make the browser check to see if this window is already open and if so not reload it I would GREATLY appreciate it. I feel like it is 1 to 2 lines of code max according to what I have seen elsewhere but just cant figure it out. Thanks a Million in advance Chris I can not figure out why my function is not working or why my alert does not pop up.. can anyone help? When you enter a total in the box, all I need to do is have a total with shipping show up in an alert box. (Minimum shipping is $1.50, if the total is over $25 shipping is 10%) <code> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CalcShipping</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> /* <![CDATA[ */ function calcShipping() { var priceInput; var total; priceInput = document.form1.subtotal.value; if (priceInput <= 25) total = 1.5 + number(priceInput); } else { total = number(priceInput) + (number(priceInput) * .1); } window.alert("Your total is $" + total + ); /* ]]> */ </script> </head> <body> <h1>To find out your shipping costs, please enter your purchase price:</h1> <form action ="" name ="form" method = "post" onsubmit="calcShipping();"> <div style="text-align: center"> <input type="text" name="subtotal" value= ""/> <input type="submit" value ="submit"/> </div> </form> </body> </html> </code> It's been many years since I've done simple javascript and html. I was wondering if javascript would be the language of choice for this project. I would like a simple matrix with individuals on the left column, and locations on the top row. Clicking in any cell turns on a green dot/box/circle or whatever. Clicking on a green whatever makes it disappear. Even more handy would be to make each cell in a row mutually exclusive of the others; turn any cell on and the other cell turns off. If anybody has thoughts or advice, I would greatly appreciate it. This is intended to be a tool for our intranet for tracking the location of key people. Thankfully, Russ using jquery and cookie plugin. i made a popup window. when the user clicks on a check box the window closes, forwards them to a new page, and then sets a cookie. i need it so that when they go back to the original page (where the popup came from) if the browser detects the cookie then the popup does not occur. I do not know why this does not work because when I alert the value of the cookie out, it gives me the correct number. something must be wrong in my logic ? code on the base page. Code: <script type="text/javascript"> var test123 = $.cookie('FBCheck'); if ( test123 != 1212){ function popup(Site) { window.open(Site,'PopupName','toolbar=no,statusbar=no, location=no,scrollbars=no,resizable=no,width=350,height=500') } } </script> code on popup (both files are in same directory) Code: $(document).ready(function() { $("#Cbox").click(function() { window.open ("http://www.google.com", "Google"); window.close(); $.cookie('FBCheck', '1212', {expires: 365, path: '/'}); }); }); The jquery source is installed as is the plugin. Thanks so much for your help in advance! I want to create dynamic Select option in form, I want that whenever user clicks on add member button then new row will get added & i have done that by taking help of DOM createElement method & I want that by using same, I want to create select option drop down list.
more or less when a user has a command pop up in this prompt they are asked to type another item from a list with an okay or cancel at the bottom how do i stop the script if a user hits cancel and move onto the calculation step and by pass the other imput prompts? sorry if this isn't the clearest, i am new at javascript. THanks in advance. I found this "game" that helps you practice regexp. I'm stuck on this one: |