JavaScript - Quick Question About Javascript Function Inputs
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? Similar TutorialsI 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); }); Hi, Ever seen on the iphone where you have to slide the slider across the screen to unlock it? I have a duplicate of this using javascript but no matter what I try I cannot make it redirect. I want the page to be redirected after the slider has gone to the other side. Heres the HTML Code: <!DOCTYPE html> <head> <meta charset='UTF-8'> <title>Slide To Unlock</title> <link rel='stylesheet' href='css/style.css'> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'></script> <script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js'></script> <script src='js/slidetounlock.js'></script> </head> <body> <div id="page-wrap"> <div id="well"> <h2><strong id="slider"></strong> <span>slide to unlock</span></h2> </div> </div> </body </html> And the javascript Code: $(function() { $("#slider").draggable({ axis: 'x', containment: 'parent', drag: function(event, ui) { if (ui.position.left > 550) { $("#well").fadeOut(); } else { // Apparently Safari isn't allowing partial opacity on text with background clip? Not sure. // $("h2 span").css("opacity", 100 - (ui.position.left / 5)) } }, stop: function(event, ui) { if (ui.position.left < 551) { $(this).animate({ left: 0 }) } } }); // The following credit: http://www.evanblack.com/blog/touch-slide-to-unlock/ $('#slider')[0].addEventListener('touchmove', function(event) { event.preventDefault(); var el = event.target; var touch = event.touches[0]; curX = touch.pageX - this.offsetLeft - 73; if(curX <= 0) return; if(curX > 550){ $('#well').fadeOut(); } el.style.webkitTransform = 'translateX(' + curX + 'px)'; }, false); $('#slider')[0].addEventListener('touchend', function(event) { this.style.webkitTransition = '-webkit-transform 0.3s ease-in'; this.addEventListener( 'webkitTransitionEnd', function( event ) { this.style.webkitTransition = 'none'; }, false ); this.style.webkitTransform = 'translateX(0px)'; }, false); }); Here 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> I have the two functions below, I want to write a function that puts them into a chart, I have the chart sorted etc but just struggling with how to get the actual validated users inputs from these two functions into the chart, I've tried document.write('<td> $' + productIndex + '</td>'); into the chart but that wouldn't work anyway as there could be multiple inputs? Just need a way to get the output really. function getProductChoice(min, max) { var getProductChoice = function(min, max){ do{ var productIndex = parseInt(prompt('Enter your product choice; 0-5', '0')); } while( isNaN(productIndex) || productIndex < min || productIndex > max); }; getProductChoice(0,5); } function getProductQuantity(max) { do{ var productIndexQuantity = parseInt(prompt('How many would you like?', '0')); } while( isNaN(productIndexQuantity) || productIndexQuantity < 0 || productIndexQuantity > max); }; getProductQuantity(MAX_QUANTITY); which is the real difference between: <script> alert('hello'); </script> and <script> function hi() {alert('hello');} </script> thanks in advance makerjoe I have taken lots of programming classes, but am now taking my first web programming class and I am getting sooooo frustrated. I have done lots of looking on the web, but am still unable to figure out why I can not make this simple assignment work. I just need some help with getting something to happen when the user hits submit. What I really want is for a new page to appear with the message using the user inputs, but I would be very happy with just getting the input to appear in the text area that I put in or even for the alert box to pop up with the input. I can work on validation code after I can get some kind of output to work..... I posted everything (due to it's small size), including my attempts to see what is working. Here is the code I have written: Code: <html> <head> <title>Name and Age</title> <script type="text/javascript"> <!-- function Submit() { alert("Does this do anything?"); var name = document.forms['NameAge'].elements[0]; var year = document.forms['NameAge'].elements[1]; var date = new Date(); var curr_yr = date.GetFullYear(); var age = (curr_yr - year) alert("<h3>Hello, " + name + ", you are " + age + " years old."</h3>"); document.close() /*if (year > curr_yr) { alert("You must enter a valid year!"); } else { document.writeln("<h3>Hello, " + name + ", you are " + age + " years old."</h3>"); document.close() }*/ document.forms['NameAge'].output.value = "<h3>Hello, " + name + ", you are " + age + " years old."</h3>"; } --> </script> </head> <body> <h1>Name and Age</h1> <form name="NameAge" onsubmit="Submit()"> <p align="left">Please Enter Your Name: <input id="name" maxlength="32" size="24" /> </p> <p align="left">Please Enter the Year You Were Born: <input id="year" maxlength="4" size="24" /> </p> <input type="submit" value="Submit" /><br /> <textarea cols="10" rows="3" name="output"></textarea> </form> </body> </html> I need to style a checkbox, so I made it into two images behind a form with hidden inputs. On click the form takes input from the other form into the hidden fields and POSTs it. Then I use PHP to grab that POST and put it back into the original form. Here are some snippets of what I am trying to do: First form input: PHP Code: <input type="text" name="email" id="email1" value="<?php if(isset($_POST['email2'])) { echo $_POST['email2']; } ?>" style="height:25px;width:270px;" /> Second form input: PHP Code: <input type="hidden" name="email2" id="email2" /> Second form submit image button: PHP Code: <input type="image" src="img/Boxchecked.jpg" value="submit" onclick="fname2.value = fname1.value; lname2.value = lname1.value; email2.value = email1.value" width="20" height="20" /> The forms work fantastic on everything but IE, which does not save the field values. How do I fix the onclick event to save them in IE? Help is much appreciated. 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 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! 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 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 I found this "game" that helps you practice regexp. I'm stuck on this one: Hi guys, just a quick question about a line break in JavaScript, where would I do it? If you see I have two math operators here and want them to be on two separate lines, were do I put the line break? Thanks Code: <!doctype html> <head> </head> <body> <script type="text/javascript"> var apples = 4+76; document.write(apples); var multiple = 54*11; document.write(multiple); </script> </body> </html> Hey everybody! I am trying to do a simple echo onclick, but despite what I try to do, it shows no errors, but won't work. I've tried things like: Code: echo "<div onclick=\"alert('test');\">t</div>"; echo '<div onclick="alert(\'test\');">t</div>'; But just can't seem to get it to work right. I'm trying to do this on a script that is being eval on the ajax request. Thus I'm having problems placing the ',", \ marks. Thanks for your time. I have a simple issue that I cannot fix. The code bellow, is a while-loop with RGB color. It displays the word Hello 10 times id 10 different colors. The problem is I cannot get the correct colors displayed. I want the first Hello to be red and end up green in the last one. For some reason I cannot get the color combination correct, even after I put 255 for red and 192 for green. Can you please have a look and tell me what am I doing wrong? Thanks in advance Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Project 4 - Exercise 10</title> </head> <body> <script language="JavaScript"> var r = 254; var g = 254; var b = 125; for (i=1; i <= 10; i++) { document.write ("<font size=7 color = rgb(" + i + "," + g + ", "+b+")> Hello <br>"); } </script> </body> </html> So i have this algorithm and im not sure how to translate it into javascript if (the Round Trip button is checked) double the fare my fare calculated works correctly based on the distance traveled, but how do i make it so that when round button is checked the fare gets doubled, im not quite sure how to make that a code i have a program where a user enters a temperature in farenheit and the program converts it to celcius. below is my code: Code: <html> <head> <title>JavaScript Assignment 4 Part 1</title> </head> <body> <h2>Welcome to the Temperature Calculator!!</h2> <script type="text/javascript"> var fTemp; var number1; var cTemp; fTemp = window.prompt( "Please enter temperature in Farenheit:", "0" ); number1 = parseInt( fTemp ); cTemp = (5/9) * (number1 - 32); document.writeln("The corresponding temperature in Celcius is: " + cTemp); </script> </body> </html> what i cant figure out is how to round off the temperature in celcius so that it doesnt display something like 26.666666666667 i tried putting math.round in "cTemp = (5/9) * (number1 - 32);" but when i do my program doesnt work any advice on how to go about doing this? thanks Here is what i'm trying to do and I'm not sure if it will work with a switch, but i'd be better than writing a million if else statements. Code: var = c var = z switch (c) { case c > 1 && < 10: z = 5; break; case c > 10 && < 20: z = 15; break; default: z = 0; } I think you see what I'm trying to do. I have a variable 'c' and it is input by the user and I want to make variable 'z' set according to what 'c' is. I know the above code doesn't work, but I'm not sure why. I've tried a million different things to try and get it to work, but it always just goes to default when it displays 'z'. Any help would be great. Thanks. function get_price() { var the_price=1000; if (this.speed=="500MGz") the_price+=200; else the_price+=100; if (this.hdspace=="15GB") the_price+=50; else the_price+=25; if (this.ram=="128MB") the_price+=150; else the_price+=75; return the_price; } function computer(speed,hdspace,ram) { this.speed=speed; this.hdspace=hdspace; this.ram=ram; this.price=get_price; } var work_computer=new computer("2GHz","80GB","1GB"); var home_computer=new computer("1.5GHz","40GB","512MB"); var laptop_computer=new computer("1GHz","20GB","256MB"); var work_computer_price=work_computer.price(); var home_computer_price=home_computer.price(); var laptop_computer=laptop_computer.price(); ___________________________________________________ In the above code, the line I'm having trouble with is marked red. Why is it that when I call the method using ... this.price = get_price; It works fine. But if I assign the object this.price with like this... this.price = get_price(); I get an error? Isn't get_price() a function? So shouldn't the parenthesis be included when the method is called? Why are we suppose to leave out the parenthesis?! I'm confused. Thanks! |