JavaScript - Question About Javascript Function
Similar TutorialsHere is my webpage (don't laugh!). If you click on Espanol it translates the page to Spanish. English is set up differently and it works too. Please tell me why clicking Spanish works but not French, Portuguese, etc. Code: <body> <p align="center"> <b id='Spanish1'><b id='French1'><b id='Portuguese1'><b id='German1'><b id='Danish1'><b id='Dutch1'><b id='Finnish1'><b id='Swedish1'><b id='Norwegian1'></b>Change Language:</b></b></b></b></b></b></b></b> <input type='button' onclick='TranslateToSpanish()' value='Espanol' style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"> <input type='button' onclick='TranslateToFrench()' value='Francais' style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"> <input type='button' onclick='TranslateToPortuguese()' value='Portuguese' style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"> <input type='button' onclick='TranslateToGerman()' value='Deutsch' style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"> <input type='button' onclick='TranslateToDanish()' value='Dansk' style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"> <input type='button' onclick='TranslateToDutch()' value='Nederlands' style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"> <input type='button' onclick='TranslateToFinnish()' value='Suomi' style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"> <input type='button' onclick='TranslateToSwedish()' value='Svensk' style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"> <input type='button' onclick='TranslateToNorwegian()' value='Norske' style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"> <a href='http://www.luxe-bux.com/the-link-of-the-same-page-viewer-is-on-so-it-will-refresh-the-page-back-to-english'><input type='button' value='English' style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"></a> <div class="header" onclick="location.href='http://www.luxe-bux.com';" style="cursor: pointer"> <img src="http://i770.photobucket.com/albums/xx344/colorscolors123/0546d64a.png"> Luxe Bux <font size="2"><b id='Spanish2'><b id='French2'><b id='Portuguese2'><b id='German2'><b id='Danish2'><b id='Dutch2'><b id='Finnish2'><b id='Swedish2'><b id='Norwegian2'></b>Luxuries For Less!</b></b></b></b></b></b></b></b></b><br>.</font></div> <div class="test"> <div class="allthestuff"> <h1><!-- Atomz HTML for Search --> <form method="get" action="http://search.atomz.com/search/" rel="nofollow" target="foo" onSubmit="window.open('', 'foo', 'width=1200,height=500,status=yes,resizable=yes,scrollbars=yes')"> <input type="hidden" name="sp_a" value="sp1004432f"> <p align="center"><font color=ffffff size=3><b id='Spanish3'><b id='French3'><b id='Portuguese3'><b id='German3'><b id='Danish3'><b id='Dutch3'><b id='Finnish3'><b id='Swedish3'><b id='Norwegian3'>Search Luxe Bux:</b></b></b></b></b></b></b></b></b></font> <input size="30" name="sp_q" style="background-color: #cb672d; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011"> <input type="submit" style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011" value="Find it!"><b id='Spanish4'></b><b id='French4'></b> <input type="hidden" name="sp_p" value="all"> <input type="hidden" name="sp_f" value="UTF-8"></p> </form> </h1> <div class="container"> <ul> <li><a class="nav" href="http://www.luxe-bux.com"><b class="ShopNow"><b id='Spanish5'><b id='French5'><b id='Portuguese5'><b id='German5'><b id='Danish5'><b id='Dutch5'><b id='Finnish5'><b id='Swedish5'><b id='Norwegian5'>Shop Now!</b></b></b></b></b></b></b></b></b></b></a></li> <li><a class="nav" href="http://www.luxe-bux.com"><b id='Spanish6'><b id='French6'><b id='Portuguese6'><b id='German6'><b id='Danish6'><b id='Dutch6'><b id='Finnish6'><b id='Swedish6'><b id='Norwegian6'>Reviews of Luxe Bux</b></b></b></b></b></b></b></b></b></a></li> <li><a class="nav" href="http://www.luxe-bux.com"><b id='Spanish7'><b id='French7'><b id='Portuguese7'><b id='German7'><b id='Danish7'><b id='Dutch7'><b id='Finnish7'><b id='Swedish7'><b id='Norwegian7'>FAQ/Return Policy/More Info</b></b></b></b></b></b></b></b></b></a></li> <li><a class="nav" href="http://www.luxe-bux.com"><b id='Spanish8'><b id='French8'><b id='Portuguese8'><b id='German8'><b id='Danish8'><b id='Dutch8'><b id='Finnish8'><b id='Swedish8'><b id='Norwegian8'>Contact</b></b></b></b></b></b></b></b></b></a></li> </ul> </div> <br> <div class="IdeaColor"> <div class="marginspacer"> <p><img alt="small-euro-currency-sign.jpg" style="padding: 15px; border: 2px solid #000000;" src="http://www.luxebux.com/sitebuildercontent/sitebuilderpictures/.pond/desaturated-and-resized-only.jpg.w180h269.jpg" align="right" vspace="0" hspace="5"></p> <p> <b id='Spanish9'><b id='French9'><b id='Portuguese9'><b id='German9'><b id='Danish9'><b id='Dutch9'><b id='Finnish9'><b id='Swedish9'><b id='Norwegian9'> <font size="4">Here's what our customers are saying...<br><br></font><br /><font size="3"> "THANK YOU VERY MUCH NICE DEALING WITH"<br> "Exceptional service overall and great care in packaging! I will buy again! A++"<br> "Exactly as advertised! Fast shipping(always takes longer to Canada) A+" <br> "great online sellers. highly recomended! will buy from again"<br> "Arrived in record time and packaged well. Thanks"<br> "Quick"<br> "Great service, very fast shipping. I will definitely buy from them again"<br> "Arrived quickly as described!!"<br><br><br><br><br><br></p> </b></b></b></b></b></b></b></b></b> </div></div> <table height="100"><tr><td></td></tr></table> <table width=100% height=20px bgcolor="#f5e9c3"> <tr><td></td></tr> </table> <script type="text/javascript"> function TranslateToSpanish() { document.getElementById('Spanish1').innerHTML = 'Lengua del cambio:'; document.getElementById('Spanish2').innerHTML = 'Lujos para menos!'; document.getElementById('Spanish3').innerHTML = 'Busqueda Luxe Bux:'; document.getElementById('Spanish4').innerHTML = '<input type="submit" style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011" value="Encuentrelo!">'; document.getElementById('Spanish5').innerHTML = 'Tienda ahora!'; document.getElementById('Spanish6').innerHTML = 'Revisiones de Luxe Bux'; document.getElementById('Spanish7').innerHTML = 'Politica de FAQ/Return/mas Info'; document.getElementById('Spanish8').innerHTML = 'Contacto'; document.getElementById('Spanish9').innerHTML = '<font size="4">Aqui es lo que estan diciendo nuestros clientes...<br><br></font><br /><font size="3">"GRACIAS EL TRATAR MUCHO AGRADABLE DE"<br>"Cuidado total y grande del servicio excepcional en el empaquetado! Comprare otra vez!"<br>"Exactamente segun lo anunciado! Envio rapido (lleva siempre mas de largo Canada)"<br>"grandes vendedores en linea. recomendado altamente! comprara de otra vez"<br>"Llegado en tiempo de registro y empaquetado bien. Grazias"<br>"Aprisa"<br>"Gran servicio, envio muy rapido. Comprare definitivamente de ellos otra vez"<br>"Llegado rapidamente segun lo descrito!!"<br><br><br><br><br><br></p>'; } </script> <script type="text/javascript"> function TranslateToFrench() { document.getElementById('French1').innerHTML = 'Lengua del cambio:'; document.getElementById('French2').innerHTML = 'Lujos para menos!'; document.getElementById('French3').innerHTML = 'Busqueda Luxe Bux:'; document.getElementById('French4').innerHTML = '<input type="submit" style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011" value="Encuentrelo!">'; document.getElementById('French5').innerHTML = 'Tienda ahora!'; document.getElementById('French6').innerHTML = 'Revisiones de Luxe Bux'; document.getElementById('French7').innerHTML = 'Politica de FAQ/Return/mas Info'; document.getElementById('French8').innerHTML = 'Contacto'; document.getElementById('French9').innerHTML = '<font size="4">Aqui es lo que estan diciendo nuestros clientes...<br><br></font><br /><font size="3">"GRACIAS EL TRATAR MUCHO AGRADABLE DE"<br>"Cuidado total y grande del servicio excepcional en el empaquetado! Comprare otra vez!"<br>"Exactamente segun lo anunciado! Envio rapido (lleva siempre mas de largo Canada)"<br>"grandes vendedores en linea. recomendado altamente! comprara de otra vez"<br>"Llegado en tiempo de registro y empaquetado bien. Grazias"<br>"Aprisa"<br>"Gran servicio, envio muy rapido. Comprare definitivamente de ellos otra vez"<br>"Llegado rapidamente segun lo descrito!!"<br><br><br><br><br><br></p> } </script> <script type="text/javascript"> function TranslateToPortuguese() { document.getElementById('Portuguese1').innerHTML = 'Lengua del cambio:'; document.getElementById('Portuguese2').innerHTML = 'Lujos para menos!'; document.getElementById('Portuguese3').innerHTML = 'Busqueda Luxe Bux:'; document.getElementById('Portuguese4').innerHTML = '<input type="submit" style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011" value="Encuentrelo!">'; document.getElementById('Portuguese5').innerHTML = 'Tienda ahora!'; document.getElementById('Portuguese6').innerHTML = 'Revisiones de Luxe Bux'; document.getElementById('Portuguese7').innerHTML = 'Politica de FAQ/Return/mas Info'; document.getElementById('Portuguese8').innerHTML = 'Contacto'; document.getElementById('Portuguese9').innerHTML = '<font size="4">Aqui es lo que estan diciendo nuestros clientes...<br><br></font><br /><font size="3">"GRACIAS EL TRATAR MUCHO AGRADABLE DE"<br>"Cuidado total y grande del servicio excepcional en el empaquetado! Comprare otra vez!"<br>"Exactamente segun lo anunciado! Envio rapido (lleva siempre mas de largo Canada)"<br>"grandes vendedores en linea. recomendado altamente! comprara de otra vez"<br>"Llegado en tiempo de registro y empaquetado bien. Grazias"<br>"Aprisa"<br>"Gran servicio, envio muy rapido. Comprare definitivamente de ellos otra vez"<br>"Llegado rapidamente segun lo descrito!!"<br><br><br><br><br><br></p> } </script> <script type="text/javascript"> function TranslateToGerman() { document.getElementById('German1').innerHTML = 'Lengua del cambio:'; document.getElementById('German2').innerHTML = 'Lujos para menos!'; document.getElementById('German3').innerHTML = 'Busqueda Luxe Bux:'; document.getElementById('German4').innerHTML = '<input type="submit" style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011" value="Encuentrelo!">'; document.getElementById('German5').innerHTML = 'Tienda ahora!'; document.getElementById('German6').innerHTML = 'Revisiones de Luxe Bux'; document.getElementById('German7').innerHTML = 'Politica de FAQ/Return/mas Info'; document.getElementById('German8').innerHTML = 'Contacto'; document.getElementById('German9').innerHTML = '<font size="4">Aqui es lo que estan diciendo nuestros clientes...<br><br></font><br /><font size="3">"GRACIAS EL TRATAR MUCHO AGRADABLE DE"<br>"Cuidado total y grande del servicio excepcional en el empaquetado! Comprare otra vez!"<br>"Exactamente segun lo anunciado! Envio rapido (lleva siempre mas de largo Canada)"<br>"grandes vendedores en linea. recomendado altamente! comprara de otra vez"<br>"Llegado en tiempo de registro y empaquetado bien. Grazias"<br>"Aprisa"<br>"Gran servicio, envio muy rapido. Comprare definitivamente de ellos otra vez"<br>"Llegado rapidamente segun lo descrito!!"<br><br><br><br><br><br></p> } </script> <script type="text/javascript"> function TranslateToDanish() { document.getElementById('Danish1').innerHTML = 'Lengua del cambio:'; document.getElementById('Danish2').innerHTML = 'Lujos para menos!'; document.getElementById('Danish3').innerHTML = 'Busqueda Luxe Bux:'; document.getElementById('Danish4').innerHTML = '<input type="submit" style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011" value="Encuentrelo!">'; document.getElementById('Danish5').innerHTML = 'Tienda ahora!'; document.getElementById('Danish6').innerHTML = 'Revisiones de Luxe Bux'; document.getElementById('Danish7').innerHTML = 'Politica de FAQ/Return/mas Info'; document.getElementById('Danish8').innerHTML = 'Contacto'; document.getElementById('Danish9').innerHTML = '<font size="4">Aqui es lo que estan diciendo nuestros clientes...<br><br></font><br /><font size="3">"GRACIAS EL TRATAR MUCHO AGRADABLE DE"<br>"Cuidado total y grande del servicio excepcional en el empaquetado! Comprare otra vez!"<br>"Exactamente segun lo anunciado! Envio rapido (lleva siempre mas de largo Canada)"<br>"grandes vendedores en linea. recomendado altamente! comprara de otra vez"<br>"Llegado en tiempo de registro y empaquetado bien. Grazias"<br>"Aprisa"<br>"Gran servicio, envio muy rapido. Comprare definitivamente de ellos otra vez"<br>"Llegado rapidamente segun lo descrito!!"<br><br><br><br><br><br></p> } </script> <script type="text/javascript"> function TranslateToDutch() { document.getElementById('Dutch1').innerHTML = 'Lengua del cambio:'; document.getElementById('Dutch2').innerHTML = 'Lujos para menos!'; document.getElementById('Dutch3').innerHTML = 'Busqueda Luxe Bux:'; document.getElementById('Dutch4').innerHTML = '<input type="submit" style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011" value="Encuentrelo!">'; document.getElementById('Dutch5').innerHTML = 'Tienda ahora!'; document.getElementById('Dutch6').innerHTML = 'Revisiones de Luxe Bux'; document.getElementById('Dutch7').innerHTML = 'Politica de FAQ/Return/mas Info'; document.getElementById('Dutch8').innerHTML = 'Contacto'; document.getElementById('Dutch9').innerHTML = '<font size="4">Aqui es lo que estan diciendo nuestros clientes...<br><br></font><br /><font size="3">"GRACIAS EL TRATAR MUCHO AGRADABLE DE"<br>"Cuidado total y grande del servicio excepcional en el empaquetado! Comprare otra vez!"<br>"Exactamente segun lo anunciado! Envio rapido (lleva siempre mas de largo Canada)"<br>"grandes vendedores en linea. recomendado altamente! comprara de otra vez"<br>"Llegado en tiempo de registro y empaquetado bien. Grazias"<br>"Aprisa"<br>"Gran servicio, envio muy rapido. Comprare definitivamente de ellos otra vez"<br>"Llegado rapidamente segun lo descrito!!"<br><br><br><br><br><br></p> } </script> <script type="text/javascript"> function TranslateToFinnish() { document.getElementById('Finnish1').innerHTML = 'Lengua del cambio:'; document.getElementById('Finnish2').innerHTML = 'Lujos para menos!'; document.getElementById('Finnish3').innerHTML = 'Busqueda Luxe Bux:'; document.getElementById('Finnish4').innerHTML = '<input type="submit" style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011" value="Encuentrelo!">'; document.getElementById('Finnish5').innerHTML = 'Tienda ahora!'; document.getElementById('Finnish6').innerHTML = 'Revisiones de Luxe Bux'; document.getElementById('Finnish7').innerHTML = 'Politica de FAQ/Return/mas Info'; document.getElementById('Finnish8').innerHTML = 'Contacto'; document.getElementById('Finnish9').innerHTML = '<font size="4">Aqui es lo que estan diciendo nuestros clientes...<br><br></font><br /><font size="3">"GRACIAS EL TRATAR MUCHO AGRADABLE DE"<br>"Cuidado total y grande del servicio excepcional en el empaquetado! Comprare otra vez!"<br>"Exactamente segun lo anunciado! Envio rapido (lleva siempre mas de largo Canada)"<br>"grandes vendedores en linea. recomendado altamente! comprara de otra vez"<br>"Llegado en tiempo de registro y empaquetado bien. Grazias"<br>"Aprisa"<br>"Gran servicio, envio muy rapido. Comprare definitivamente de ellos otra vez"<br>"Llegado rapidamente segun lo descrito!!"<br><br><br><br><br><br></p> } </script> <script type="text/javascript"> function TranslateToSwedish() { document.getElementById('Swedish1').innerHTML = 'Lengua del cambio:'; document.getElementById('Swedish2').innerHTML = 'Lujos para menos!'; document.getElementById('Swedish3').innerHTML = 'Busqueda Luxe Bux:'; document.getElementById('Swedish4').innerHTML = '<input type="submit" style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011" value="Encuentrelo!">'; document.getElementById('Swedish5').innerHTML = 'Tienda ahora!'; document.getElementById('Swedish6').innerHTML = 'Revisiones de Luxe Bux'; document.getElementById('Swedish7').innerHTML = 'Politica de FAQ/Return/mas Info'; document.getElementById('Swedish8').innerHTML = 'Contacto'; document.getElementById('Swedish9').innerHTML = '<font size="4">Aqui es lo que estan diciendo nuestros clientes...<br><br></font><br /><font size="3">"GRACIAS EL TRATAR MUCHO AGRADABLE DE"<br>"Cuidado total y grande del servicio excepcional en el empaquetado! Comprare otra vez!"<br>"Exactamente segun lo anunciado! Envio rapido (lleva siempre mas de largo Canada)"<br>"grandes vendedores en linea. recomendado altamente! comprara de otra vez"<br>"Llegado en tiempo de registro y empaquetado bien. Grazias"<br>"Aprisa"<br>"Gran servicio, envio muy rapido. Comprare definitivamente de ellos otra vez"<br>"Llegado rapidamente segun lo descrito!!"<br><br><br><br><br><br></p> } </script> <script type="text/javascript"> function TranslateToNorwegian() { document.getElementById('Norwegian1').innerHTML = 'Lengua del cambio:'; document.getElementById('Norwegian2').innerHTML = 'Lujos para menos!'; document.getElementById('Norwegian3').innerHTML = 'Busqueda Luxe Bux:'; document.getElementById('Norwegian4').innerHTML = '<input type="submit" style="background-color: #794011; color: #ffffff; border-width: thin; border-style: dotted; border-color: 794011" value="Encuentrelo!">'; document.getElementById('Norwegian5').innerHTML = 'Tienda ahora!'; document.getElementById('Norwegian6').innerHTML = 'Revisiones de Luxe Bux'; document.getElementById('Norwegian7').innerHTML = 'Politica de FAQ/Return/mas Info'; document.getElementById('Norwegian8').innerHTML = 'Contacto'; document.getElementById('Norwegian9').innerHTML = '<font size="4">Aqui es lo que estan diciendo nuestros clientes...<br><br></font><br /><font size="3">"GRACIAS EL TRATAR MUCHO AGRADABLE DE"<br>"Cuidado total y grande del servicio excepcional en el empaquetado! Comprare otra vez!"<br>"Exactamente segun lo anunciado! Envio rapido (lleva siempre mas de largo Canada)"<br>"grandes vendedores en linea. recomendado altamente! comprara de otra vez"<br>"Llegado en tiempo de registro y empaquetado bien. Grazias"<br>"Aprisa"<br>"Gran servicio, envio muy rapido. Comprare definitivamente de ellos otra vez"<br>"Llegado rapidamente segun lo descrito!!"<br><br><br><br><br><br></p> } </script> </body></html> Is it possible to have an input that points to some other function? For example: Code: function someFunction() { alert('It worked.'); } function doAnotherFunction(doIt, otherFunction) { if (doIt == true) { otherFunction(); } } <input type="button" value="test" onClick="doAnotherFunction(true, someFunction());"> Or would I need a switch statement and have all the various functions hardcoded? which is the real difference between: <script> alert('hello'); </script> and <script> function hi() {alert('hello');} </script> thanks in advance makerjoe Hi, I'm having some issues turning this "Please Wait"/Disabled button into a function. Code: <input type="submit" value="Submit Form" onClick="this.disabled = 'true'; this.value='Please wait...';" /> Code: function pleasewait() { this.disabled = 'true'; this.value='Please wait..' } <input type="submit" value="Submit Form" onClick="pleasewait();" /> Thanks much Hi, I am facing a problem in passing replace() function as an argument in user defined java function, can any one help me how to resolve it? intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '\' to '\\' I am posting my javascript function he <a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\\/g,"\\\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a> function OpenDocPreview(url, docname) { alert('message from search base : ' + url + ' ' + docname); } thank you, How can I call a PHP Function inside a Javascript Function? This is what I have so far, but I don't think I'm doing it the right way. Any suggestions? PHP Code: <?php function phpQuery(){ $query = mysql_query("INSERT INTO mytable VALUES('','name','email')"); } ?> <script type="text/javascript"> function delayQueries() { timeoutID = window.setTimeout(doQueries, 2000); } function doQueries() { var runQuery = "<?php phpQuery(); ?>"; } </script> I made a mouseover event of a caption on a picture, when I hover the opacity of the background color of the hover and the text goes down. What I want is that when I hover over the image which the caption is floating on, the onmouseover event gets activite. For an imaginary example: Code: function unhighlight(x) { x.style.backgroundColor="transparent" } Function ActivationFuction() { activate.function="unhighlight" } thanks Hi everyone, I am pretty new at javascript OOP. I have a javascript file that has plenty of javascript functions, variables, arrays, etc. I need to convert this into an object. Here is an example: Code: var myvar1 = ''; var myvar2 = new array(); var myvar3 = new array(); var myvar4; var myvar5 = 60; var myvar6 = ''; function myfunc1(){ myvar1 = 'hello'; return myvar1; } function myfunc2(somenum=0){ myvar5 = somenum; //calling myfunc1() from within this function. //do something in here } function myfunc3(){ //calling myfunc1() from within this function. for(i=0;i<somelength;i++){ myvar2 = myvar3[i]; (something to put into the array) } } 1. I need to create an object and put ALL the varibles (myvar1 - myvar5) in that object. 2. Then the first two functions "myfunc1 and myfunc2" inside the same object. 2. And the function myfunc3 needs to sit OUTSIDE my object as a regular javascript function. It calls on myfunc1 (which is inside the object) and also inserts data into myvar2 (which is classified inside the object) and myvar3 (which is classified inside the object as well). This is what i came up with, but it's not going well: Code: var myobj1 = function(){ this.myvar1 = ''; this.myvar2 = new array(); this.myvar3 = new array(); this.myvar4; this.myvar5 = 60; this.myvar6 = ''; var myfunc1 = function(){ this.myvar1 = 'hello'; return this.myvar1; } var myfunc2 = function(somenum=0;){ this.myvar5 = somenum; //calling this.myfunc1() from within this function. //do something in here } } function myfunc3(){ //calling mynewobj.myfunc1() from within this function. for(i=0;i<somelength;i++){ mynewobj.myvar2 = mynewobj.myvar3[i]; (something to put into the array) } } var mynewobj = myobj1; HELP.....!!!! i really want to get into object oriented world, so thanks in advance. I have a dice simulator. Basically, a user enters how many sides they want on their die, and then I digitally roll 2 of them. And produce the output in a document.writeln. I think I'm having trouble with the this.sides in the constructor function (in the head section). Also, I'm getting a syntax error in Safari : 25TypeError: 'null' is not an object (evaluating 'element.value') Am I not suppose to put the variable in the constructor function? Any help would be appreciated. <head> var element = document.getElementById("number"); var sides = element.value; function Die( ) { this.sides = sides; this.roll = function( ) { return parseInt((Math.random( ) * 1000) % this.sides) + 1; } } </script> </head> <body> <h1>Adam's Dice Rolling Game!</h1><br/> <form action="" method="post"> <p> <input type="text" name="number" id="number"/> </p> <p> <input type="button" value="Roll the dice!" id="roll_me"/> </p> </form> <script type="text/javascript"> var d = new Die( ); d.sides = sides; var rolled_value = d.roll( ); var r1 = document.getElementById( "roll_me" ); r1.onclick = function Die () { document.writeln ( d.roll () ); } </script> $.fn.superfish = function(op) { } So I see here that a function is being declared and the name of the function is '$.fn.superfish'. Is there any special meaning at all behind the $ in this situation? Hello I have a question which has been bugging me for a while now so have decided to ask it on CF. In PHP you can use the '&' symbol as a function operator for example like so. PHP Code: function demoFunc(&$output='') { for($i=1;$i<count(func_get_args());$i++) { $output .= ' '.func_get_arg($i); } $output = trim($output); } As you can see the '&' symbol was used in the argument section to allow the function to be used like this demoFunc($output,'hello','world'); print $output; My question is how can I do this in JavaScript to do the same thing like use the variable used in the function argument section and use it like it would be used in PHP? Thank you - DJCMBear Hi there I am wondering if anyone can tell me the best way to access the functions of an Iframe from the parent of the frame. I have tried Code: var myFrame = document.getElementById('gigmap'); myFrame.flashMouseover(gid); and Code: window.frames['gigmap'].document.flashMouseover(gid); though these didn't work. Basically this is what i want: Mainpage function a(id) receives flash variable 'id' then sends variable 'number' to iframe function b(id) . The part in red is where I have the problem. In case you are wondering what I am doing is sending an id of a gig in my database when its button rolled over in a flash swf to a Google Map (using Google maps javascript API inside the Iframe 'gigmap) and make the corresponding marker on the map jump. I have it so the iframed map markers send to the flash file on rollover though not the other way round...yet! I've been going through this great tutorial on how to implement a type-ahead feature on a text field and there's something which hopefully you guys can explain. On the third page there is this function. Code: AutoSuggestControl.prototype.init = function () { var oThis = this; this.textbox.onkeyup = function (oEvent) { if (!oEvent) { oEvent = window.event; } oThis.handleKeyUp(oEvent); }; }; What I don't understand is this line: this.textbox.onkeyup = function (oEvent) { I know about anonymous functions, but I don't know where the value for the parameter oEvent is going to come from. Can someone explain this? Thanks! :) Hi! This is probably a classic inheritance thing... I have two objects, C1 and C2. Both contains a callback method named 'callback'. Now, if I let C2 inherit from C1, then C1's 'callback' gets overridden by C2's. The problem is I still want C1's methods to access their own 'callback' method. Is this possible, and is it "valid"? Am I headed down disaster lane here? Should I re-think and refactor? Example: Code: function C1 () {}; C1.prototype.callback = function () { console.log('c1 called'); }; C1.prototype.call = function () { //do stuff this.callback(); }; function C2 () {}; C2.prototype = new C1(); C2.prototype.callback = function () { console.log('c2 called'); }; var obj = new C2(); obj.call(); Output: c2 called Regards Don If I use function or Function to create a javascript function, does it make any difference ? Whats the difference between two and in which situation shall I use either ? Likewise whats the difference between event and Event objects of JavaScript ? Thanks Hello, I have a php function PHP Code: function npclocs() { $npcl=$db->query("SELECT * FROM npclocation WHERE npclong < {$ir['userlongitute']}+5 AND npclong > {$ir['userlongitute']}-5 AND npclat > {$ir['userlatitude']}-5 AND npclat < {$ir['userlatitude']}+5 "); /*$npcarray = mysql_fetch_array($npcl);*/ $rows =0; while($row = $db->fetch_row($npcl)) { $nloc[]=$row; } foreach($nloc as $n) { echo "newpoints[" . $rows . "] = new Array(".$n['npclong'].", ".$n['npclat'].", ".$n['npciicon'].", ".$n['npclname'].", ".$n['npclname']."); "; $rows++; } } and I have a javascript function that I would like the results of this function to insert its results in the javascript here is the function in javascript Code: function addPoints() { //newpoints[0] = new Array(-73, 46, icon0, 'monroe', 'monroepopup'); //newpoints[1] = new Array(-69, 52, icon0, 'jackson', 'jacksonpopup'); //newpoints[2] = new Array(-45, 39, icon0, 'Benton', 'bentonpopup'); for(var i = 0; i < newpoints.length; i++) { var point = new GPoint(newpoints[i][1],newpoints[i][0]); var popuphtml = newpoints[i][4] ; var marker = createMarker(point,newpoints[i][2],popuphtml); map.addOverlay(marker); } } The commented out //newpoints is the old js array. my php function queries mysql and uses whiles and foreach to create the same output, as the old js array. I would like that php function result to insert its result into the js function. Is this possible? Thank you in advance. Please I have been having sleepless nights for days and could not resolve why this codes will not work. I will appreciate any assistance to resolve the coding reerroll the main problem is the function calculate (), does work when called. Please help <HTML> <HEAD> <TITLE>Feedback</TITLE> <SCRIPT TYPE="TEXT/JAVASCRIPT"> rate = new Array(4) rate[0] = 8 rate[1] = 4 rate[2] = 6 rate[3] = 12 function calculate() { howmuch = eval("document.form1.InsVal.Value") for(loop = 0; loop < document.form1.cover.length;loop++) if (document.form1.cover[loop].checked) level = loop + 1 where =document.form1.region.selectedIndex cost = eval(10 + howmuch /100*rate[where]*level) document.form1.guote.value =cost } function confirmPurchase() { if (confirm("Area you sure you wish to purchase insurance from us?")) document.form1.submit() } </SCRIPT> </HEAD> <BODY> <H1 ALIGN = CENTER>HotWheels</H1> <H2 ALIGN = CENTER>Skateboard Insurance Specialists</H2> <FORM NAME = form1 METHOD = post ACTION = "mailto:ioduwa@yahoo.com"> <P><B> Value of board:</B> <INPUT TYPE = text NAME = InsVal SIZE = 10> <P> Region <SELECT NAME= region> <OPTION = london> London <OPTION = southwest> South West <OPTION = rest>Rest of England <OPTION = wales>Wales </SELECT> <BR><INPUT TYPE = Radio NAME = cover> Third Party <BR><INPUT TYPE = Radio NAME = cover> Third Party Fire and Theft <BR><INPUT TYPE = Radio NAME = cover CHECKED> Comprehensive <P><INPUT TYPE = "button" NAME = "calc" VALUE = "Get guote" onClick ="calculate()"> <P><B> Your Quotation:<B> <INPUT TYPE = "text" NAME = "quote" SIZE = 10> <P><INPUT TYPE = "button" NAME = "done" VALUE = "Purchase" onClick = "comfirmPurchase()"> </FORM> </BODY> </HTML> Hi, I have a javascript code in my site which is similar to this: var menu1=new Array() menu1[0]='<hr style="color: \'#FFCC66\'; height: \'1\'; text-align: \'left\'; width: \'96%\'"><strong><font size=+2>text1</font></strong>' var menu2=new Array() menu2[0]='<hr style="color: \'#FFCC66\'; height: \'1\'; text-align: \'left\'; width: \'96%\'"><strong><font size=+2>text2</font></strong>' The list goes on for hunders of records. What I need to do, is to use a function in which I will pass the text1, text2, text3 as variables, and have the html code returned, since it's always the same. For example, I would need something like: var menu1=new Array() menu1[0]='display_html(text1)' var menu2=new Array() menu1[0]='display_html(text2)' This would save me a lot of bytes in the output file, but I'm not very familiar with javascript so I didn't manage to make it work. I tried using the document.write command in a function, but that forced the text to be displayed on my page, even though it was supposed to be shown only when the user clicks on a link. I'm using the "AnyLink Drop Down Menu" script from www.dynamicdrive.com. Any help would be highly appreciated! Hi I have a JavaScript function that has leaves floating around the screen and I need a way to have a checkbox turn on and off the function. Or I need a way to have a button turn off the script. I have the code to start the function on-loading the site. Any ideas are greatly appreciated. I got the falling leaves script from http://javascript.about.com/gi/o.htm...tip62.htm%3Ffm HI Guys!! My name is Megan and I am a college student in need of some JavaScript help for my computer science class!! My professor is making us complete some stupid class project for finals and I can't figure it out! He suggested that we may try to find a JavaScript Website to help us if we have trouble figuring out how to write the code. I have looked and looked and can't find out how to fix my code!! We have to write code to make a slot machine .. I have started the code based on what he gave us and have tried my hardest to figure out how to complete it but I do not know how to finish it. I have the images working correctly (kind of.. the second one seems to have problems loading? I dunno what I did to mess that up) and the counter working, but I need to make it add 13 credits when all 3 images are the same. I added code that I thought would work but it's not for some reason that I can't figure out. It should also pop up an alert screen when all 3 are correct and you win. I guess this would have to be including with the if statement and something like alert('You win 12 credits!!!') Lastly I need to add code that prevents the person from playing when the credit line is 0 (so you can't get - credits!) and I have no idea how to do this. Any help would be greatly appreciated! Here's what I have so far! HI Guys!! My name is Megan and I am a college student in need of some JavaScript help for my computer science class!! My professor is making us complete some stupid class project for finals and I can't figure it out! He suggested that we may try to find a JavaScript Website to help us if we have trouble figuring out how to write the code. I have looked and looked and can't find out how to fix my code!! We have to write code to make a slot machine .. I have started the code based on what he gave us and have tried my hardest to figure out how to complete it but I do not know how to finish it. I have the images working correctly (kind of.. the second one seems to have problems loading? I dunno what I did to mess that up) and the counter working, but I need to make it add 13 credits when all 3 images are the same. I added code that I thought would work but it's not for some reason that I can't figure out. It should also pop up an alert screen when all 3 are correct and you win. I guess this would have to be including with the if statement and something like alert('You win 12 credits!!!') Lastly I need to add code that prevents the person from playing when the credit line is 0 (so you can't get - credits!) and I have no idea how to do this. Any help would be greatly appreciated! Here's what I have so far! Code: <html> <head> <title> Slot Machine</title> <script type="text/javascript" src="http://balance3e.com/random.js"></script> <script type="text/javascript"> function SpinSlots() // Assumes: slot images are in http://balance3e.com/Images // Resultes: displays 3 random slot images { var slot1, slot2, slot3; slot1 = RandomOneOf(['lemon', 'cherry', 'bar']); slot2 = RandomOneOf(['lemon', 'cherry', 'bar']); slot3 = RandomOneOf(['lemon', 'cherry', 'bar']); document.getElementById('slot1Img').src = 'http://balance3e.com/Images/' + slot1 + '.jpg'; document.getElementById('slot2Img').src = 'http://balance3e.com/Images/' + slot2 + '.jgp'; document.getElementById('slot3Img').src = 'http://balance3e.com/Images/' + slot3 + '.jpg'; document.getElementById('credits').innerHTML = parseFloat(document.getElementById('credits').innerHTML) - 1; if (slot1 == slot2 == slot3) { document.getElementById('credits').innerHTML = parseFloat(document.getElementById('credits').innerHTML) + 13; } } </script> </head> <body> <div style="text-align:center"> <p> <img id="slot1Img" border=1 alt="slot image" src="http://balance3e.com/Images/cherry.jpg"> <img id="slot2Img" border=1 alt="slot image" src="http://balance3e.com/Images/lemon.jpg"> <img id="slot3Img" border=1 alt="slot image" src="http://balance3e.com/Images/bar.jpg"> </p> <input type="button" value="Click to Spin" onclick="SpinSlots();"> <p> Credits Remaining: <spin id="credits">20</span> </p> </div> </body> </html> |