JavaScript - One Works, Duplicate Doesnt, Help!
Hello Guys,
im writing a big page with several different elements in it, and im stuck trying to duplicate a script. first one works "tab b" click each 'icon' and a .png file appears above it to show its selected. "tab c" same script and code seems to only work for first icon, and switch off when clicked on the others. been staring at this for sooooome time now, please can someone see what i have done wrong, as i dont really understand the code im using, im just a beginner. url is http://www.zakscustomcues.com/module...builder2.0.php much appreciated. steve Similar TutorialsThis script is supposed to tally the score of the questions. It shows up fine but it does not tally the score <p>You are on a business journey beyond traditional small business style <input type="checkbox" value="1" name="Q1">yes <input type="checkbox" value="0" name="Q1">no</p> <p>You don t want to be the glue holding everyday operations together <input type="checkbox" value="1" name="Q1">yes <input type="checkbox" value="0" name="Q1">no</p> <p>You are comfortable with using simple business technology tools and the web <input type="checkbox" value="1" name="Q1">yes <input type="checkbox" value="0" name="Q1">no</p> <p>You believe in business operations based upon processes <input type="checkbox" value="1" name="Q1">yes <input type="checkbox" value="0" name="Q1">no</p> <p>You earn operating success by having a good working team <input type="checkbox" value="1" name="Q1">yes <input type="checkbox" value="0" name="Q1">no</p> <p>One of your high priorities is designing and evolving your business progressively <input type="checkbox" value="1" name="Q1">yes <input type="checkbox" value="0" name="Q1">no</p> <p>Your company culture embraces adopting the best approaches <input type="checkbox" value="1" name="Q1">yes <input type="checkbox" value="0" name="Q1">no</p> <p>You have defined processes, roles, and responsibilities <input type="checkbox" value="1" name="Q1">yes <input type="checkbox" value="0" name="Q1">no</p> <p>Your staff is literate in using a computer for your basic on the job tasks <input type="checkbox" value="1" name="Q1">yes <input type="checkbox" value="0" name="Q1">no</p> <p>You are ready to begin implementing more systematic operations <input type="checkbox" value="1" name="Q1">yes <input type="checkbox" value="0" name="Q1">no</p> <p>You want to expand, grow, or diversify more efficiently <input type="checkbox" value="1" name="Q2">yes <input type="checkbox" value="0" name="Q2">no</p> <p>You effectively communicate the reasons and value of your changes <input type="checkbox" value="1" name="Q3">yes <input type="checkbox" value="0" name="Q3">no</p> <p>You want to adopt changes to smooth out basic team processes <input type="checkbox" value="1" name="Q3">yes <input type="checkbox" value="0" name="Q3">no</p> <p>Your key people will support, advocate, and lead in changes for you <input type="checkbox" value="1" name="Q3">yes <input type="checkbox" value="0" name="Q3">no</p> <p>You view change as a prime mover in your business journey <input type="checkbox" value="1" name="Q3">yes <input type="checkbox" value="0" name="Q3">no</p> <p><input type="text" name="tally" size="5"></p> <p><input type="button" value="tally" name="B1"></p> function hasTagsInText(text) { if(text.indexOf("<TABLE") >=0 || text.indexOf("<table") >=0) return 'table'; ///this line of code doesnt work in firefox Hello Guys and Gals, I have got my head around using the jquery validate and submit without refresh and implemented it successfully on a front end form. Now I would like to streemline backend updating by enabling submit without refresh for multiple items on a page, validation would be nice but less important. what I would like to do is something like adding 'here' to the function and 'this' to the form but im not sure how exactly. here is the code im using Code: <title>Untitled Document</title> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script> <script type="text/javascript" src="js/jquery.validate.js"></script> <script type="text/javascript" src="js/jquery.form.js"></script> <script type="text/javascript"> $('document').ready(function(){ $('#form').validate({ rules:{ // your validation rules }, messages:{ // and validate msgs }, submitHandler: function(form){ $(form).ajaxSubmit({ target: '#preview', success: function() { // take these lines out if you dont want to hide the form after submit $('#formbox').slideUp('slow'); ///////////////// } ///////////////////////////////////////////// }); } }) }); </script> </head> <div id="preview"> </div> <div id="formbox"> <form id="0" name="0" method="post" action="timbersend.php" > <label>name</label> <input type="text" name="name" /> <label>value</label> <input type="text" name="value" /> <input type="submit" value="submit" name="submit" /> </form> </div> <body> </body> thanks steve Can anyone please tell me what im doing wrong? Code: <script type = "text/javascript"> function submitallforms() { setTimeout('document.forms[0].submit()',100); setTimeout('document.forms[1].submit()',200); setTimeout('document.forms[2].submit()',300); } </script> <NOSCRIPT>This shopping-cart needs JavaScript. Please enable JavaScript in your browser's preferences.</NOSCRIPT> <script> if(typeof navigator.cookieEnabled=="boolean" && !navigator.cookieEnabled) alert("You need to enable Cookies in your browser, before this shopping-cart will work for you!"); </script> <!-- <script src=noper-language-pdt.utf8.js></script> --> <script src=http://www.mlpdecals.com/cgi/nopercart.js></script> <FORM name="0" action="shoppingcart.htm" method=GET onSubmit="return AddToCart(this)"> <font class=bigtext><b>Special Instructions:</b></font><br> <input type=text size=32 maxlength=200 name=USERTEXT> <input type=hidden _PRICE="0.00" _QUANTITY="1" _NAME="special-instructions" _ID="nSPCI"> </FORM> <br><br> <FORM name="0" action="shoppingcart.htm" method=GET onSubmit="return AddToCart(this)"> <font class=bigtext><b>Special Instructions:</b></font><br> <input type=text size=32 maxlength=200 name=USERTEXT> <input type=hidden _PRICE="0.00" _QUANTITY="1" _NAME="special-instructions" _ID="nSPCI"> </FORM> <br> <br> <input type=submit value="Submit" onclick="submitallforms();"> Im new to javascript and trying to make a form validator, ive succeeded but its left me confussed as to setting variables. my original code was Code: function applyform() { var name = document.getElementById('mainname'); var lvl = document.getElementById('mainlvl'); var class = document.getElementById('mainclass'); var role = document.getElementById('mainrole'); var reason = document.getElementById('reason'); var age = document.getElementById('age'); var mic = document.getElementById('microphone'); var voice = document.getElementById('voice'); if(notempty(name, "Please enter your main characters name")){ if(dropselect(lvl, "Please select your characters level")){ if(dropselect(class, "Please select your characters class")){ if(dropselect(role, "Please select your characters role")){ if(notempty(reason, "Please tell us why you wish to join us")){ if(notempty(age, "Please state your age")){ if(notempty(mic, "Please state if you have a microphone")){ if(notempty(voice, "Please state if you will use voice communication during events")){ return true; } } } } } } } } return false; } using this stoped all my javascript functions working but i cant see any fault with it. I've changed the code now to Code: function applyform() { if(notempty(document.getElementById('mainname'), "Please enter your main characters name")){ if(dropselect(document.getElementById('mainlvl'), "Please select your characters level")){ if(dropselect(document.getElementById('mainclass'), "Please select your characters class")){ if(dropselect(document.getElementById('mainrole'), "Please select your characters role")){ if(notempty(document.getElementById('reason'), "Please tell us why you wish to join us")){ if(notempty(document.getElementById('age'), "Please state your age")){ if(notempty(document.getElementById('microphone'), "Please state if you have a microphone")){ if(notempty(document.getElementById('voice'), "Please state if you will use voice communication during events")){ return true; } } } } } } } } return false; } this works fine but i don't get why my first bit of code didnt work and id really appreciate someone explaining it to me. thanks in advance Hi, on my page below: http://www.jbiddulph.com/helix/events.html I have a navigation of 1,2,3,4,5which when a user clicks on a different number the image changes, I need to have this navigation for the 4 other large boxes underneath?! I can't work out how to go about this?! please help here is the code to the page Code: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Helix</title> <link type="text/css" rel="stylesheet" href="css/reset.css"> <link rel="stylesheet" type="text/css" href="css/style.css" title="default" /><!--[if lte IE 7]> <style type="text/css"> html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/ </style> <![endif]--> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="js/jquery.cycle.all.min.js"></script> <script type="text/javascript"> $(function() { $('#slideshow').after('<div id="nav" class="nav">').cycle({ fx: 'fade', speed: 'fast', timeout: 0, pager: '#nav', befo onBefore }); function onBefore() { $('#title').html(this.alt); } }); </script> </head> <body> <div id="top"> <div id="topwrapper"> <div id="logo"> </div> <ul id="rightnav"> <li><a href="index.html" title="Home">Home</a></li> <li><a href="news.html" title="News">News</a></li> <li><a href="archives.html" title="Archives">Archives</a></li> <li><a href="finishes.html" title="Finishes">Finishes</a></li> <li><a href="contact.html" title="Contact">Contact</a></li> </ul> <nav> <ul> <li><a href="events.html" title="HELIX EVENTS" class="menuselected">HELIX EVENTS</a></li> <li><a href="marketing.html" title="HELIX MARKETING">HELIX MARKETING</a></li> <li><a href="film.html" title="HELIX FILM & TV">HELIX FILM & TV</a></li> <li><a href="exhibitions.html" title="HELIX EXHIBITIONS">HELIX EXHIBITIONS</a></li> <li><a href="interiors.html" title="HELIX COMMERCIAL INTERIORS">HELIX COMMERCIAL INTERIORS</a></li> </ul> </nav> <div class="line"> </div> </div> </div> <div id="content"> <section id="slider" style="background-color: rgb(160, 191, 74);"> <div id="viewport"> <div id="container"> <div id="section-1" class="section"> <img src="images/slider_01.png"> </div> </div> </div> </section> <div class="line"> </div> <h1>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</h1> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> <div class="dashedlinetop"> </div> <div id="box"> <div id="slideshow" class="pics"> <img src="images/box1.jpg" alt="1"/> <img src="images/box2.jpg" alt="2"/> <img src="images/box3.jpg" alt="3"/> <img src="images/box4.jpg" alt="4"/> <img src="images/box5.jpg" alt="5"/> </div> </div> <div class="dashedlinebottom"> </div> <div class="dashedlinetop"> </div> <div id="box"> <div id="slideshow" class="pics"> <img src="images/box1.jpg" alt="1"/> <img src="images/box2.jpg" alt="2"/> <img src="images/box3.jpg" alt="3"/> <img src="images/box4.jpg" alt="4"/> <img src="images/box5.jpg" alt="5"/> </div> </div> <div class="dashedlinebottom"> </div> <div class="dashedlinetop"> </div> <div id="box"> <div id="slideshow" class="pics"> <img src="images/box1.jpg" alt="1"/> <img src="images/box2.jpg" alt="2"/> <img src="images/box3.jpg" alt="3"/> <img src="images/box4.jpg" alt="4"/> <img src="images/box5.jpg" alt="5"/> </div> </div> <div class="dashedlinebottom"> </div> <div class="dashedlinetop"> </div> <div id="box"> <div id="slideshow" class="pics"> <img src="images/box1.jpg" alt="1"/> <img src="images/box2.jpg" alt="2"/> <img src="images/box3.jpg" alt="3"/> <img src="images/box4.jpg" alt="4"/> <img src="images/box5.jpg" alt="5"/> </div> </div> <div class="dashedlinebottom"> </div> <div class="dashedlinetop"> </div> <div id="box"> <div id="slideshow" class="pics"> <img src="images/box1.jpg" alt="1"/> <img src="images/box2.jpg" alt="2"/> <img src="images/box3.jpg" alt="3"/> <img src="images/box4.jpg" alt="4"/> <img src="images/box5.jpg" alt="5"/> </div> </div> <div class="dashedlinebottom"> </div> </div> <!-- end content --> </body> </html> I would like to count how many duplicate values I have in an array. My below attempt doesnt count the duplicate values: Code: var ct = 0; for(var i = 0;i < myArray.length;i++) { var myData = getData[i].city; if(myData == myData) { ct++; } alert("Total Count = " + ct); } Please advise the best way to do this. disregard...i got it
when i run applet nothing shows jsut text field [highlight=Java] import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Assign6 extends JApplet implements ActionListener { JLabel answerLabel; JTextField answerField; public void init() { Container c = getContentPane(); c.setLayout (new FlowLayout()); answerLabel = new JLabel(""); answerField = new JTextField(10); answerField.setEditable(true); answerField.addActionListener(this); c.add(answerLabel); c.add(answerField); } public int generateNumbers() { int x=0; x = 1 + (int)(Math.random() * 10); return x; } public void actionPerformed(ActionEvent e) { String correct = new String("Correct "); int x = generateNumbers(); int y = generateNumbers(); showStatus("How much is " + x + " times " + y); int answer; answer = Integer.parseInt(answerField.getText()); int product = x*y; if (product == answer){ showStatus("Very good!"); } else showStatus("No. Please try again."); } @Override public void paint(Graphics g) { super.paint(g); } } { } [/highlight] Hey guys I have a stupid problem, my teacher asked us to DONT use javadscript in html (like onchange ="....") If i use following js in html my page works: <select id="car" name="car" onchange="configurator()"> If i delete that last piece and try to code it in a .js file like: document.getElementsById("car").onchange = configurator; it doesnt work, it doest recognize the .onchange method Thanks in advance I have a problem with one simple script, which works in every browser, just not in IE6 and IE7. You can see the script at http://bbtalk.eu/iframe.html - when you click on the iframe, you should see "clicked at the bottom". But it doesnt work in IE6 and IE7. Do anyone know how to fix that? Thank you
<html> <script language="javascript"> function checkForm() { String name= document.getElementById("name"); if(name.length==0) return ; // else // return ; } </script> <body> <form action="test2.jsp" onclick =" return checkForm()"> <input type="text" name="name" value="shyam" id="name" /> <input type="submit" name="sub" value="clickme" /> </form> </body> </html> I use a basic pop-up window code that i have used for many years. I probably need to update it, but i was wondering why it will work for every browser but IE8. Can anyone help? Code: function popUp(URL) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=600,height=400,left = 540,top = 325');"); } Code: <a href="javascript:popUp('/email/agent/aid/<?php echo $this->agent->pers_code?>')" > can anyone see something that may cause the problem? Thanks for any help! OMG, Check out the background on this site... http://paulirish.com/ how would I even start to rip that for use on my own site? I'll pay someone $15 on paypal if they can make a css and js file that I can just link too and have this background
Is there a method or a way to duplicate the text typed in one textarea to another, with onkeyup or onchange? The problem I'm facing is with FCKeditor. Two textareas with loaded templates and the text has to be manually copied and pasted when changed. Code: <form action="" method="post" name="form1" id="form1"> Subject:<br /> <input type="text" name="subject" value="Subject" size="32" /> <br /> Main Article:<br /> <textarea name="content" cols="50" rows="10"> <?php echo $row['article']; ?> </textarea> <br /> Text version:<br /> <textarea name="content_text" cols="50" rows="10"> <?php echo $row['article']; ?> </textarea> <input type="submit" value="Send" /> </form> I may be going about this all wrong? Send newsletters, it all works - not sure? do I need the second texarea. Greetings and salutations. My text and what I have been researching on the internet has not been very helpful in determining the code that I need to prevent a user from entering his/her information more than once. Here is my current code Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD.HTML 4.01 Transitional//EN" "http://www.w3.org/TR/htm14/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Kudler Fine Foods Contact Page</title> <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"> <!---Kami Demnyan 21 December 2009--> <script type="text/javascript"> /*<![CDATA[*/ <!--This code ensures that the zip code and telephone numbers are actual numerical digits, not letters--> function checkForNumber(fieldValue) { var numberCheck = isNaN(fieldValue); if (numberCheck == true) { window.alert ("Please enter a numerical value"); return false; } } <!--This code ensures that all of the fields contain text and I have it functioning now--> function submitForm() { if (document.forms[0].name.value == "" || document.forms[0].address.value == "" || document.forms[0].city.value == "" || document.forms[0].state.value == "" || document.forms[0].zip.value == "" || document.forms[0].phone.value == "" || document.forms[0].email.value == "") { window.alert("Please enter your missing information"); return false; } else return true; } function getCookie(NameOfCookie) { if (document.cookie.length > 0) { begin = document.cookie.indexOf(NameOfCookie+"="); if (begin != -1) { begin += NameOfCookie.length+1; end = document.cookie.indexOf(";", begin); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(begin, end)); } } return null; } function setCookie(NameOfCookie, value, expiredays) { var ExpireDate = new Date (); ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000)); document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()); } function delCookie (NameOfCookie){ if (getCookie(NameOfCookie)) { document.cookie = NameOfCookie + "=" +"; expires=Tues, 02-Feb-10 00:00:01 GMT"; } } /*]]>*/ </script> </head> <body> <h1> KUDLER FINE FOODS </h1> <h2> JOIN OUR MAILING LIST</h2> <!--This is where the user will input all of their information to join the mailing list--> <form action="completeform.html" method="get" onsubmit="return submitForm();" enctype="application/x-www-form-urlencoded"> <p>Name<br /> <input type="text" name="name" size="50" /></p> <p>Address<br /> <input type="text" name="address" size="50" /></p> <p>City, State, Zip <br /> <input type="text" name="city" size="30" /> <input type="text" name="state" size="3" /> <input type="text" name="zip" size="10"; onchange="return checkForNumber(this.value)"; /></p> <p>Telephone<br /> <input type="text" name="phone" size="25" onchange="return checkForNumber(this.value)"; /></p> <p>Email Address<br /> <input type="text" name="email" size="50" /></p> <!--This is where the submit and reset buttons are located--> <p><input type="submit" value="Submit Form" /> <p><input type="reset" value="Reset Form" /> </form> </body> </html> I have created a new web page to link the duplicate cookie too, titled doubleinfo.html. This is what I am using to let the user know that their information has already been entered. My text is telling me that I need to look for a nextform() function, but I didn't have to write one so what would I need to do, if anything, to start the document.cookie = "name" codes? Any help would be greatly appreciated, thanks in advance. Hi All, Im trying to add some content by JS (which ive done) but i cant click a link i have made; JS: Code: function game() { document.getElementById('title').innerHTML = '<p style="float: left; text-decoration: underline; font-weight: bold;">Deady Teddy</p><img src=css/images/popup/close.png style="float: right; cursor: hand;" href="javascript: hideModal("modalPage");"></img>'; } *Yes i know about the Href but if i put "onClick" it gives errors*; HTML: Code: <a href="javascript:void(0);" onClick="javascript: revealModal('modalPage'); game();">Deady Teddy </a> And place its adding it to: Code: <div id="modalPage"> <div class="modalBackground"></div> <div class="modalContainer"> <div class="modal"> <div class="modalTop" id="title" onselectstart='return false'> </div></div></div></div> Any Idea's? Hey Everyone, Thanks for reading my thread, I really hope I'm not asking a dumb question as I am teaching myself java but here goes. I'm a bit stuck and want my code to output a message when a form input does not contain a word (like lets say codingforums.com). I know it outputs my message when the field is left blank but here's what I have, any help will be greatly appreciated Thanks. Code: function checkPostFields(form) { var msg = ''; var value_missing = false; if (form.elements['test'].value == '' ) { msg += '<?php echo $errormessage; ?>\n'; value_missing = true; } } Trying to have my navigation have an on click and selected state, but I am not able to do so with this code (website is: http://bit.ly/rgwsite ) Code: $('nav li a').click(function() { $(this).parent().addClass('on').siblings().removeClass('on'); }); nav li is as follows Code: <nav> <li class="highlt"> <a href="index.php" class="home"><span>Home</span></a> </li> The reason we need to use a jquery/javascript action to add the class to the navigation is because it doesn't refresh when a new page loads. For instance, when you're on the home page and click on the tab "Experience RGW", it only loads the content for that page below the header (within the "#ajax" div). Currently, none of these scripts are working. There is no reason they shouldn't... could there be something else causing the page not to recognize the jquery script and run it on-click? The main reason I ask is because I've tried to test the function and add an alert, but even that didn't work Hi there It's huge problem for me but I don't think it is for many of you here. I have been asked at the college to make a manual lottery checker using javascript, but I found lots of problem during the coding. To make it more clear it's about 3 players they always play the same set of 6 number between 1 and 49. the players enter manually the winning number using a prompt which popup when you open the page (No button required for this, just simple prompt). each time you type duplicate number an alert tells that this number been entered, when the six number been successfully entered will ask for the bonus ball the same way but it should between 1 and 49 as well. When this done the program print out for each player the much numbers. This my peace of coding but I stucked in many bits in it. I need your knowledge guys in javascript to fix this for me. Code: <html> <head> <title>Lottery Checker</title> <h1>Lottery Checker</h1> </head> <body> <script type="text/javascript"> //Declare Variable var number1 = [3, 9, 18, 27, 30, 33]; var number2 = [5, 7, 11, 12, 34, 42]; var number3= [4, 15, 21, 23, 27, 31]; var drawNumber = []; var bonusBall = []; //Declare variable Times and Dates var currentTime = new Date(); var day = currentTime.toUTCString(); // Print out the player set numbers document.write("<h4>You visited the lottery website at :</h4>" + day); //Print out Times and Dates document.write('<p>Player number 1 : '+ number1 +'</p>'); document.write('<p>Player number 2 : '+ number2 +'</p>'); document.write('<p>Player number 3 : '+ number3 +'</p>'); //Copare Lottery Number arrays //Add input number using prompt to add the 6 bonus number and the bonus ball for (var i=0 ; i<=5 ; i++) { drawNumber[i] = prompt("Enter the Lottery draw Number."); drawNumber.sort(function(a, b){return a-b}); //Fix the lottery Numbers between 1 and 49 while (drawNumber[i]<1 || drawNumber[i]>49) { drawNumber[i] = prompt("The lottery Number should be between 1 and 49"); // to insert Prompt insteat the Alert } if (drawNumber[i] = drawNumber) // if statement to be checked again { alert('You already entered this number');// if statement to be checked again } } document.write('<p>The winning lottery number for this week: '+drawNumber+ ', The bonus number: '+ drawNumber[6] + '</p></br>'); //Sort the winning number by each player // Display the result for each player how many number much document.write('Player 1 winning numbers: ' + drawNumber +'</br>'); document.write('Player 2 winning numbers: ' + drawNumber +'</br>'); document.write('Player 3 winning numbers: ' + drawNumber +'</br>'); </script> </body> </html> |