JavaScript - Check If Value Is In Array, Won't Work Correctly
Hiya,
I'm looking for some guidance on a part of some coding practice I'm stuck on! I've created a shopping cart using javascript, the items save to the arrays etc and it all works fine. If the user adds the same product again to the cart the quantity is added onto the previous quantity that is already in the cart. To check if the item is already in the cart I've ued the below code, but what it does is update the quantity for the first cart, and when it updates the quantity for the second item it updates the quantity but keeps adding the same product to the cart in seperate elements of the array as well (if that makes sense? here are the two functions used: Code: function additem(id) { itemName = document.getElementById('name' + id).innerHTML; itemQuantity = parseInt(document.getElementById('quantity' + id).value); itemPrice = parseFloat(document.getElementById('price' + id).innerHTML); if(numitems == 0){ items[++numitems] = new Item(itemName,itemPrice,itemQuantity); displaycart(); } else{ checkarray(id, itemName, itemQuantity, itemPrice); } } function checkarray(id, itemName, itemQuantity, itemPrice){ for(i=1;i<=numitems;i++) { if(items[i].name == itemName){ items[i].quantity += parseInt(document.getElementById('quantity' + id).value); displaycart(); return true; } items[++numitems] = new Item(itemName,itemPrice,itemQuantity); } } It may jsut be a simple mistake I've made but it's been bugging me a lot and I can't seem to fix it, any help/pointers would be greatly appreciated. Similar TutorialsI am sorry if this is a stupid question. I have never really used javascript before. I found some code online that I tried to piece together so I might not even be going about this the right way. I want the background to take up 100% and resize with the browser. That works fine. I also want the text "welcome to the ahi life" stick to the bottom left hand corner and the enter button to stick to the bottom right. I would like these to resize with the browser as well. It all kind of works, except the first time you load the page the text and the button are much smaller than I would like them to be. If you refresh the page everything is correct. The url is http://www.ahiapparel.com/landing.html Code: <style> * { margin: 0; padding: 0; } #bg { position: fixed; top: 0; left: 0; } .bgwidth { width: 100%; } .bgheight { height: 100%; } #page-wrap { position:absolute; bottom:0; left:20px; width: 700px; margin: 50px auto;} #welcometext { position: fixed; bottom: 20px; left: 25px; } .welcometextwidth { width: 7%; } .welcometextheight { height: 7%; } #entertext { position: fixed; bottom: 20px; right: 25px; } .entertextwidth { width: 7%; } .entertextheight { height: 7%; } </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script> $(function funct1() { var theWindow = $(window), $bg = $("#bg"), aspectRatio = $bg.width() / $bg.height(); function resizeBg() { if ( (theWindow.width() / theWindow.height()) < aspectRatio ) { $bg .removeClass() .addClass('bgheight'); } else { $bg .removeClass() .addClass('bgwidth'); } } theWindow.resize(function() { resizeBg(); }).trigger("resize"); }); $(function funct2() { var theWindow = $(window), $welcometext = $("#welcometext"), aspectRatio = $welcometext.width() / $welcometext.height(); function resizewelcometext() { if ( (theWindow.width() / theWindow.height()) < aspectRatio ) { $welcometext .removeClass() .addClass('welcometextheight'); } else { $welcometext .removeClass() .addClass('welcometextwidth'); } } theWindow.resize(function() { resizewelcometext(); }).trigger("resize"); }); $(function funct3() { var theWindow = $(window), $entertext = $("#entertext"), aspectRatio = $entertext.width() / $entertext.height(); function resizeentertext() { if ( (theWindow.width() / theWindow.height()) < aspectRatio ) { $entertext .removeClass() .addClass('entertextheight'); } else { $entertext .removeClass() .addClass('entertextwidth'); } } theWindow.resize(function() { resizeentertext(); }).trigger("resize"); }); </script> My best guess is that either the functions or some of the variables are conflicting somehow, but I have tried just about everything to fix it. Any help would be much appreciated. Thanks! Hi guys. I'm working a bunch of pre existing code on a CMS. Just after a quick fix. Doing a show/hide thing on a particular div somewhere on the page depending if a checkbox is ticked or not. Currently there is 3 checkboxes that are dynamically added through the CMS. Here's simplified version of the form: Code: <form id="simplesearch" name="simplesearch"> <input type="checkbox" onclick='showhidefield(this.value)' name="meta_data_array_search_criteria[custom_profile_type][]" value="5" class="input-checkboxes" /> <input type="checkbox" onclick='showhidefield(this.value)' name="meta_data_array_search_criteria[custom_profile_type][]" value="4" class="input-checkboxes" /> </form> And here's the javascript I was playing with. Code: function showhidefield(id) { if(document.simplesearch.meta_data_array_search_criteria[custom_profile_type][''].checked) { document.getElementById("profile_fields_wrapper_" + id).style.visibility = "visible"; } else { document.getElementById("profile_fields_wrapper_" + id).style.visibility = "hidden"; } } Problem I'm having is how do i do a check to see if those checkboxes are checked in the javascript with those name arrays? How do i separate them? 'm guessing I have to loop through them or something?Hopefully that make senses - it's late here and I'm losing the plot Any pointers would be gratefully welcomed I wrote js functions to reset a php form (multiple questions). The below works: Code: function resetForm(){ resetGroup(document.forms[0].answer1); resetGroup(document.forms[0].answer2); } Answer1 and answer2 are the elements of $_POST array. (<input name="answer1"> in php). In this example, I tried with only two questions, but I have up to 35 questions in one form. Instead of writing the above resetGroup() 35 times, I want to for-loop it. I tried Code: function resetForm(){ for (var i=1; i<3; i++){ resetGroup(document.forms[0]."answer"+i); } That didn't work. Could someone help me to make the loop work? Or would someone have better or simpler idea? Thanks. Hello, i wrote this code to open a page if doesn't exist a cookie but it doesn't open the page do you know where I wrong? Thank you ! 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> <title> HTML </title> </head> <body> <script type="text/javascript"> function CookieLeggi(CookieNome) { if (CookieNome.length==0) return null; var PosizioneIniziale = document.cookie.indexOf(CookieNome+"="); if (PosizioneIniziale == -1) return null; PosizioneIniziale += CookieNome.length+1; var PosizioneFinale = document.cookie.indexOf(";",PosizioneIniziale); if (PosizioneFinale == -1) PosizioneFinale = document.cookie.length; return unescape(document.cookie.substring(PosizioneIniziale,PosizioneFinale)); } function CookieScrivi(name,value,expiresUdM,expires,path,domain,secure) { if (!name || !value) { return false } if ((expiresUdM && expires) && (expiresUdM!='GMT')) { var ExpiresMillisec = ExpiresDate = Oggi = new Date(); switch (expiresUdM) { // calcola i JS-millisecondi del momento di scadenza case "anni": ExpiresMillisec=Oggi.getTime()+expires*365*24*60*60*1000; break; case "mesi": ExpiresMillisec=Oggi.getTime()+expires*31*24*60*60*1000; break; case "giorni": ExpiresMillisec=Oggi.getTime()+expires*24*60*60*1000; break; case "ore": ExpiresMillisec=Oggi.getTime()+expires*60*60*1000; break; case "minuti": ExpiresMillisec=Oggi.getTime()+expires*60*1000; break; case "secondi": ExpiresMillisec=Oggi.getTime()+expires*1000; break; default: ExpiresMillisec=Oggi.getTime()+expires; } ExpiresDate.setTime(ExpiresMillisec); expires = ExpiresDate.toGMTString(); } secure = (secure=="1" || secure==1 || secure=="secure") ? 1 : ""; document.cookie = name + "=" +escape(value) + ( (expiresUdM && expires) ? "; expires=" + expires : "") + ( (path) ? "; path=" + path : "") + ( (domain) ? "; domain=" + domain : "") + ( (secure) ? "; secure" : ""); if (CookieLeggi(name)==null && secure!=1) { return false; } else { return true; } } </script> <script type="text/javascript"> if (CookieLeggi(liveads) == "null") { window.open("http://www.google.com", "Google"); CookieScrivi(liveads, adsm, ore, 12, /, .localhost, 1); } else { break; } </script> </body> </html> I have been banging my head on the wall with this one for a few hours. I mostly only program bash so this is a new world for me. I am trying to have a script check a list of zip codes(preferably from a file) and if it is there it passes it to an order page and if not it goes to another URL. The basic idea is to check if you are within a service area before you can purchase a product. I have gotten nowhere fast with this so any help you can offer would be appreciated. I am currently trying to check using javascript whether a php array contains a variable, and if it does then display a message. Any help would be much appreciated. I have written the following code... Code: <?php //php which sets users array to the results of the sql $selectquery = "SELECT Username FROM User"; $selectresult = mysql_query($selectquery); while ($row = mysql_fetch_array($selectresult)){ $users[] = $row['Username']; } ?> <script language="javascript" type="text/javascript"> function verifyUsername(array_var){ var user = document.getElementById("username").value; for(var i=0; i<array_var.length; i++){ if(array_var[i] == user){ document.getElementById("usernameerror").textContent = "already in array"; } } } </script> //html code for the form Username: <input type="text" name="username" id="username" onblur="return verifyUsername(<?php $users?>)"/> <span id="usernameerror" class="red"></span> Hello I am trying to find a way to use the check all javascript code to select all my checkboxes within a while...loop. Codes goes as follows: within the header on the top of page 1: <SCRIPT LANGUAGE="JavaScript"> function CheckAll(chk) { for (i = 0; i < chk.length; i++) chk[i].checked = true ; } function UnCheckAll(chk) { for (i = 0; i < chk.length; i++) chk[i].checked = false ; } </script> The code that displays the checkboxes, which is a page included onto page 1: echo "<a class='comp' onclick='singleHideandShow({$row['pr_id']})' style='cursorointer'>{$row['propname']}</a><p>"; $propqry = mysql_query("SELECT * FROM users WHERE propid={$row['pr_id']}"); //using the hide and show id number, once clicked it will display the below contents echo "<div id={$row['pr_id']} style='display:none;'>"; while($propf = mysql_fetch_assoc($propqry)) { if($propf['uactive'] == "yes") { $pactive = "active"; } else { $pactive = "deactivated"; } //displays the information from the DB with a checkbox echo "<form name='myform' id='formmsg' method='post' action='profile.php?paction=edit&find=none' >"; echo " <input type='checkbox' name='check_list' value='{$propf['us_id']}'> <a href='profile.php?paction=edit&pid={$propf['us_id']}' /><img src='../images/secure/edit.png' name='Edit' border='0' /></a> <a href='profile.php?paction=delete&pid={$propf['us_id']}' /><img src='../images/secure/delete.png' name='Delete' border='0' /></a><label class='cuser'> {$propf['fname']} {$propf['lname']}, ({$propf['uname']}), {$pactive}</label><br>"; } echo "</form>"; echo '<p><input type="button" name="Check_All" value="Check All" onClick="CheckAll(document.myform.check_list)"> <input type="button" name="Un_CheckAll" value="Uncheck All" onClick="UnCheckAll(document.myform.check_list)"> <p>'; echo "</div>"; I receive the following error message when I click on the Check All button. Message: 'length' is null or not an object Line: 15 Char: 13 Code: 0 URI: http://www.domainname.com/profile.ph...edit&find=none Can anyone help me figure this out? I've been trying for several hours to solve this University problem but I'm just unable to get it done. I'm supposed to create a function that takes an array with all the A,B,C,D ... and shift them one place to the right (for instance array of A,B,C,D should be shifted and be like D,A,B,C - the last character goes to first position) Here is the code that I've been dealing with: Code: var abcArray = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; function shift(anyArray) { var newArray = Array(anyArray.length); for (var position = 0; position < newArray.length; position = position + 1) { if (position == 0) { newArray[position] = anyArray[anyArray.length - 1]; } else { newArray[position] = anyArray[position - 1]; } } anyArray = newArray; } shift(abcArray); document.write(abcArray); If I remove the function and try this code directly on the array it does work, but when I use the code as it is just like you see - the function shift doesn't change the Array and doesn't shift the values inside one position to the right and I have no clue why. Anyone has some ideas?! How would I go about having this work for Firefox. Is there away to have JQuery work with it? Code: <script type="text/javascript"> region=[//2 dimensional array containing area codes and region pairs ["201","nj"], ["202","dc"], ] function getRegion(code){ index=0; while(true){ console.log(index); if(region[index][0]==code){ return(region[index][1]); } index++; if(index>=region.length){ return(undefined); } } } function getLocation(number){ out=document.getElementById('output'); var answer; if(number.length<3){ return(void(0)); } else{ var code=number.substring(0,3); answer=getRegion(code) if(answer==undefined){ out.innerText="unknown area code"; } else{ out.innerText=answer; } } } </script> ... <form> <input type="text" id="number" onkeyup="getLocation(this.value)"> </form> <div id="output"> </div> anotherVar should be -1 if there are no matches, but it doesn't seem to work
PHP Code: var string = "abadafa"; var matches = string.match(/a/gi); //doesn't work with /z/ for example var anotherVar = matches.length || -1; The default operator should return the second value if the first is null or false, and according to PHP Code: try { alert(matches.length); } catch (e){ alert(e); //alerts null } it's null. fyi: http://helephant.com/2008/12/javascr...ault-operator/ What's going on? 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>Slayeroffice Image Slider (altered)</title> <script> var img = new Array(); img[0] = "http://www.blogsdna.com/wp-content/uploads/2011/03/Google-labs.png"; img[1] = "http://thenextweb.com/socialmedia/files/2010/07/youtube_logo.png"; img[2] = "http://www.techlifeweb.com/facebook_logo.jpg"; img[3] = "http://hackingarticles.com/wp-content/uploads/gmail_logo_stylized.png"; for(var image=[], p=0; p<img.length; p++){ image[p] = new Image(); image[p].src = img[p]; } var current = 0; window.onload = function so_init() { if(!document.getElementById || !document.createElement){ return; } for(var q=0; q<img.length; q++){ imgs = document.createElement("img"); imgs.src = img[q]; img[q].style.display = "none"; document.getElementById("imageContainer").appendChild(imgs.cloneNode(true)); } for(i=1;i<img.length;i++){ img[i].xOpacity = 0; } img[0].style.display = "block"; img[0].xOpacity = .99; setTimeout(so_xfade,1000); } function so_xfade() { cOpacity = imgs[current].xOpacity; nIndex = imgs[current+1] ? current+1 : 0; nOpacity = imgs[nIndex].xOpacity; cOpacity-=.05; nOpacity+=.05; img[current].xOpacity = cOpacity; img[nIndex].xOpacity = nOpacity; img[nIndex].style.display = "block"; setOpacity(img[current]); setOpacity(img[nIndex]); if(cOpacity<=0) { img[current].style.display = "none"; current = nIndex; setTimeout(so_xfade,1000); } else { setTimeout(so_xfade,100); } } function setOpacity(obj) { if(obj.xOpacity>.99) { obj.xOpacity = .99; return; } obj.style.opacity = obj.xOpacity; obj.style.MozOpacity = obj.xOpacity; obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")"; } </script> <style> #imageContainer { height:309px; } #imageContainer img { width:500px; height:309px; position:absolute; top:0; left:0; } </style> </head> <body> <div id="imageContainer"> <!-- <img src="http://www.blogsdna.com/wp-content/uploads/2011/03/Google-labs.png" alt="Swimming Pool Water" /> <img src="http://thenextweb.com/socialmedia/files/2010/07/youtube_logo.png" alt="Notebook" /> <img src="http://www.techlifeweb.com/facebook_logo.jpg" alt="Bottle Neck" /> <img src="http://hackingarticles.com/wp-content/uploads/gmail_logo_stylized.png" alt="Nail in a Board" /> --> </div> </body> </html> The script works if the images are stored within the HTML but when I try to store them in the JS array, it fails. Is there any way to store the images in JS with this script? On this webpage http://www.corkdiscos.com/testimonials.html i have a like button. when a user clicks like a comment box appears. when i unlike the button the comment box disappears this is ok but when a user has already liked the facebook page and comes to my webpage the comment box does not show. so im looking for a piece of javascript to check if a user has like the button on my page and if so to show the comment box. please check my source code of the website http://www.corkdiscos.com/testimonials.html to see what i have so far. any help would be greatly appreciated Hello all, I made a fade script that will fade any element in or out. Works great on all browser I've tested but IE 7. With IE I have only tested this will IE 8 and IE 7. IE 7 the effect doesn't work. No error message or anything. I'm unsure what to do from here. I was hoping I could find some help here. Code: function fade(obj, duration, toggle) { steps = 1000; elem = document.getElementById(obj); function fadeIn() { for(var i = 0; i <= 1; i+=(1/steps)) { setTimeout("elem.style.opacity = "+ i +"", i * duration); setTimeout("elem.style.filter='alpha(opacity="+ i * 102 +")'", i * duration); } } function fadeOut() { for(var i = 0; i <= 1; i+=(1/steps)) { setTimeout("elem.style.opacity = "+ (1-i) +"", i * duration); setTimeout("elem.style.filter='alpha(opacity="+ (1-i) * 102 +")'", i * duration); } } /* One for Fade in and anything will be fade out*/ if(toggle == 1) { fadeIn(); } else { fadeOut(); } } Thanks, Jon W I have a form and javascript that doesn't work correctly. I think there's a problem with the javascript, but it's possible the form is the culprit. I'm new at this. Here is the form code for a search boxx: Code: <form id="search" method="get" name="search" action="promotions.html"> <input type="text" size="15" name="ws" maxlength="500" value="pen, keychain, etc." onfocus="this.value='';return false;" /> <button type="submit" value="Search">Go</button> <input type="hidden" name="ID" value="64857723-2161-4778-BDEB-3EE622F6CFF3" /> </form> Here is the javascript that's in the head of /promotions.html: Code: <script type="text/javascript"> function FrameRedirect() { var q = window.location.search; q = (q.length > 1) ? q.substring(1, q.length) : 0; var s = q.substring(0, 2); switch (s) { case 'ws': q = 'http://www.asiconnection.com/ProductSearch/LinkInQS.aspx?'+q; document.getElementById('Content').className = 'active'; break; case 'bn': q = q.substring(3,q.length); document.getElementById('RD2').className = 'active'; break; default: document.getElementById('RD1').className = 'active'; break; } iframe = '<iframe id="frame" src="'+q+'" width="780" scrolling="yes" frameborder="0" height="500"></iframe>'; document.getElementById('Content').innerHTML = iframe; } </script> The search box code is suppose to send the inputted search word to the javascript on /promotions.html page and then load the search results http://www.asiconnection.com/Product.../LinkInQS.aspx into the iframe on that page. The only thing that appears in that iframe is "Oops. Firefox cannot find productsearch" Can someone help me figure this out? Thanks in advance. I have some javascript code: first it gets string of the url in the address bar then it splits the string at the ? and grabs the right half it then makes an IFrame go to that string(which is yet another url I would manually insert) here is the code: Code: function redirect(){ var raw=window.document.location.href; if(content_address_start=raw.indexOf("?")!=-1){ var content_address=raw.split("frame.html?")[1]; window.document.getElementById('content').src=content_address; } } 'content' is the id of the IFrame, and frame.html is the html file this code is inside. Ok, so everything works perfectly when I test this code offline, but as soon as I load it to my website, and the .src line occurs, it just loads a blank page in the IFrame. What could be causing this? Perhaps certain sites will not allow themselves to be inside iframes? Much thanks in advance. I hope I gave enough information and relayed my problem clearly. EDIT: It seems that the code works on other sites, just not youtube. Why would it do this and are there any ways around it? I would like this image gallery to sit behind everything else. right now white shows through on either side. Any help would be greatly appreciated. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="Generator" content="Get Hosting With Joe (13.0.1.020)"> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"> <title>Home</title> <script type="text/javascript" src="wpscripts/jquery.js"></script> <script type="text/javascript" src="wpscripts/jquery.timers.js"></script> <script type="text/javascript" src="wpscripts/jquery.wpgallery.js"></script> <script type="text/javascript"> var nImgNum_pg_2 = 0; wp_imgArray_pg_2 = new Array(); wp_imgArray_pg_2[nImgNum_pg_2++] = new wp_galleryimage("wpimages/6ec6f779d991.jpg", 844, 369, "wpimages/6ec6f779d991t.jpg", ""); wp_imgArray_pg_2[nImgNum_pg_2++] = new wp_galleryimage("wpimages/8dcdb90c2d41.jpg", 844, 370, "wpimages/8dcdb90c2d41t.jpg", ""); </script> <style type="text/css"> body {margin: 0px; padding: 0px;} </style> <script type="text/javascript" src="wpscripts/jspngfix.js"></script> <script type="text/javascript"> var blankSrc = "wpscripts/blank.gif"; </script> <script type="text/javascript"> $(document).ready(function() { $('#wp_gallery_pg_2').wpgallery({ imageArray: wp_imgArray_pg_2, nTotalImages: nImgNum_pg_2, nGalleryLeft: 77, nGalleryTop: -183, nGalleryWidth: 844, nGalleryHeight: 842, nImageDivLeft: 0, nImageDivTop: 0, nImageDivWidth: 844, nImageDivHeight: 842, nControlBarStyle: 0, nControlBarExternalTop: 10, bNavBarOnTop: false, bShowNavBar: false, nNavBarAlignment: 0, strNavBarColour: 'none', nNavBarOpacity: 1.0, nNavBarIconWidth: 24, nNavBarIconHeight: 24, bShowCaption: false, bCaptionCount: true, strCaptionColour: '#ffffff', nCaptionOpacity: 0.6, strCaptionTextColour: '#000000', nCaptionFontSize: 12, strCaptionFontType: 'Courier New,Arial,_sans', strCaptionAlign: 'center', strCaptionFontWeight: 'normal', bShowThumbnails: false, nThumbStyle: 1, nThumbPosition: 0, nThumbLeft: 30, nThumbTop: 732, nThumbOpacity: 0.5, nTotalThumbs: 2, nThumbSize: 40, nThumbSpacing: 10, bThumbBorder: false, strThumbBorderColour: '#000000', strThumbBorderHoverColour: '#ffffff', strThumbBorderActiveColour: '#ffffff', bShowThumbnailArrows: false, nThumbButtonSize: 24, nThumbButtonIndent: 50, nColBorderWidth: 2, nTransitionStyle: 1, nStaticTime: 3044, nTransitTime: 1015, bAutoplay: true, loadingButtonSize: 38, bPageCentred: true, nPageWidth: 1000, nZIndex: 100, loadingButtonSrc: 'wpimages/wpgallery_loading_1.gif', blankSrc: 'wpscripts/blank.gif', rewindButtonSrc: 'wpimages/wpgallery_rewind_0.png', prevButtonSrc: 'wpimages/wpgallery_previous_0.png', playButtonSrc: 'wpimages/wpgallery_play_0.png', pauseButtonSrc: 'wpimages/wpgallery_pause_0.png', nextButtonSrc: 'wpimages/wpgallery_next_0.png', forwardButtonSrc: 'wpimages/wpgallery_forward_0.png', thumbRewindButtonSrc: 'wpimages/wpgallery_rewind_0.png', thumbForwardButtonSrc: 'wpimages/wpgallery_forward_0.png', rewindoverButtonSrc: 'wpimages/wpgallery_rewind_over_0.png', prevoverButtonSrc: 'wpimages/wpgallery_previous_over_0.png', playoverButtonSrc: 'wpimages/wpgallery_play_over_0.png', pauseoverButtonSrc: 'wpimages/wpgallery_pause_over_0.png', nextoverButtonSrc: 'wpimages/wpgallery_next_over_0.png', forwardoverButtonSrc: 'wpimages/wpgallery_forward_over_0.png', thumboverRewindButtonSrc: 'wpimages/wpgallery_rewind_over_0.png', thumboverForwardButtonSrc: 'wpimages/wpgallery_forward_over_0.png', strRewindToolTip: 'Reverse', strPreviousToolTip: 'Previous', strPlayToolTip: 'Play', strPauseToolTip: 'Pause', strNextToolTip: 'Next', strForwardToolTip: 'Forward', strThumbRewindToolTip: 'Reverse', strThumbForwardToolTip: 'Forward' }); }) </script> </head> <body text="#000000" style="background-color:#ffffff; text-align:center; height:1200px;"> <div style="background-color:transparent;text-align:left;margin-left:auto;margin-right:auto;position:relative;width:1000px;height:1200px;"> <div id="wp_gallery_pg_2" style="position:absolute; left:77px; top:-183px; width:844px; height:842px; overflow:hidden;"></div> <img src="wpimages/wp7d3e6c5d_06.png" width="997" height="1197" border="0" alt="" onload="OnLoadPngFix()" style="position:absolute;left:0px;top:3px;"> </div> </body> </html> IE, Chrome, and Safari all display this page correctly: http://eataustineat.com/testfolder2/ here is what i mean by Firefox displays it incorrectly in firefox: 1) type 'f' into the search field 2) you should move over to a youtube video 3) now click the Search tab at the bottom 4) you should notice the a portion of the video remains visable. the site uses jquery for the slider. what should I be looking for? I thought this would be simple. Evidently it's not With the date below (and it being 11.45 on the 27th as I type this), the counter returns the correct number of hours/mins/seconds remaining, but shows 33 days. It seems to be adding 31 days to the count, but I can't figure out where Code: function countdown(){ var bigday = new Date(2009,10,29,14,30,0,0); var today = new Date(); var difference = bigday - today; var remaining = Math.floor(difference/1000); // want seconds, not milliseconds var days = Math.floor(remaining/86400); remaining = remaining % 86400; var hours = Math.floor(remaining/3600); remaining = remaining % 3600; var minutes = Math.floor(remaining/60); remaining = remaining % 60; seconds = Math.floor(remaining); var out = days + " days, " + hours + " hours, " + minutes + " minutes and " + seconds + " seconds left..."; $('#countdown').text(out); setTimeout(countdown, 1000); } Hi Guys, I'm trying to do up a contact form that after a user submits the information, the drop down contact box will slide back up instead of redirecting to another page. The script works fine in Chrome and Safari, but Firefox and IE keeps redirecting to the php page. Hope someone can shed some light here, thanks! Html form: Code: <div class="left"> <!-- Login Form --> <form class="clearfix" action="contactengine.php" name="cform" method="post"> <h4>Drop us a mail</h4> <label class="grey" for="emailName">Name:</label> <input class="field" type="text" name="emailName" id="emailName" value="" size="23" /> <label class="grey" for="emailFrom">Email Address:</label> <input class="field" type="text" name="emailFrom" id="emailFrom" value="" size="23" /> <label class="grey" for="message">Message:</label> <textarea type="text" name="message" id="message" size="23"></textarea> <div class="clear"></div> <input type="submit" rows="" cols="" name="submit" value="Submit" class="bt_register" /> <span id="messageSent">Message sent successfully!</span> </form> <script language="JavaScript" type="text/javascript"> //You should create the validator only after the definition of the HTML form var frmvalidator = new Validator("cform"); frmvalidator.addValidation("emailName","req","Please enter your Name"); frmvalidator.addValidation("emailName","maxlen=20", "Max length for Name is 20"); frmvalidator.addValidation("emailFrom","maxlen=50", "Max length for email is 50"); frmvalidator.addValidation("emailFrom","req","Please enter your Email"); frmvalidator.addValidation("emailFrom","email","Please enter a valid email"); </script> </div> <div class="left right"> <!-- Register Form --> <h4>Contact Details</h4> <p class="grey"><b>XXX<br /></b>XXX<br />XXX<br />XXX</p> <p class="grey">T: 999<br />F: 999</p> <h5>Stalk Us</h5> <a href="index.html"><img src="misc/fb.png" border="0" alt="Facebook" /></a> <a href="index.html"><img src="misc/twit.png" border="0" alt="Twitter" /></a> </div> </div> </div> <!-- The tab on top --> <div class="tab"> <ul class="login"> <li class="left"> </li> <li>Hello there</li> <li class="sep">|</li> <li id="toggle"> <a id="open" class="open" href="#">Contact Us</a> <a id="close" style="display: none;" class="close" href="#">Close Panel</a> </li> <li class="right"> </li> </ul> </div> <!-- / top --> The Slider JS: Code: $(document).ready(function() { // Expand Panel $("#open").click(function(){ $("div#panel").slideDown("slow"); }); // Collapse Panel $("#close").click(function(){ $("div#panel").slideUp("slow"); }); // Switch buttons from "Hey There | Contact us" to "Close Panel" on click $("#toggle a").click(function () { $("#toggle a").toggle(); }); //submission scripts $('div#panel').submit( function(){ //statements to validate the form var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; var email = document.getElementById('emailFrom'); if (!filter.test(emailFrom.value)) { $('.email-missing').show(); } else {$('.email-missing').hide();} if (document.cform.emailName.value == "") { $('.name-missing').show(); } else {$('.name-missing').hide();} if (document.cform.message.value == "") { $('.message-missing').show(); } else {$('.message-missing').hide();} if ((document.cform.emailName.value == "") || (!filter.test(email.value)) || (document.cform.message.value == "")){ return false; } if ((document.cform.emailName.value != "") && (filter.test(email.value)) && (document.cform.message.value != "")) { //hide the form $('.div#panel').hide(); //show the loading bar $('.loader').append($('.bar')); $('.bar').css({display:'block'}); //send the ajax request $.post('contactengine.php',{emailName:$('#emailName').val(), emailFrom:$('#emailFrom').val(), message:$('#message').val()}, //return the data function(data){ //hide the graphic $('.bar').css({display:'none'}); $('.loader').append(data); }); //waits 2000, then closes the form and fades out $("#messageSent").show("slow"); setTimeout('$("#toggle a").toggle(); $("div#panel").slideUp("slow")', 2000); //stay on the page return false; } }); }); The PHP Code: PHP Code: <?php $EmailFrom = "xxx@xxx.com"; $EmailTo = "xxx@xxx.com"; $Subject = Trim(stripslashes($_POST['Webmail'])); $Name = Trim(stripslashes($_POST['emailName'])); $Email = Trim(stripslashes($_POST['emailFrom'])); $Message = Trim(stripslashes($_POST['message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Email Adress: "; $Body .= $Email; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, Webmail, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=success.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> |