JavaScript - One Script Overwriting Another
Hi all, Im still learning as i go here so please bare with me. Im completely stuck any help would be greatly apreciated.
I have two scripts 1 to hide or show a large div in the middle of the page. Inside each of these hidden divs is a small gallery with 2 thumbnails using another script. both scripts work fine until you click a thumbnail it loads its larger image as it should however at this point the other script seems to be overwritten and doesnt work properly. Heres the showonly script for the hidden divs: Code: function showonly(thechosenone) { var shoediv = document.getElementsByTagName("div"); for(var x=0; x<shoediv.length; x++) { name = shoediv[x].getAttribute("name"); if (name == 'shoediv') { if (shoediv[x].id == thechosenone) { shoediv[x].style.display = 'block'; } else { shoediv[x].style.display = 'none'; } } } } Heres the code for the thumbnail gallerys: Code: $(document).ready(function(){ $(".viper_stone_thumbs a, .viper_black_thumbs a, .titan_cuoio_thumbs a, .titan_black_thumbs a, .pheonix_taupe_thumbs a, .hawk_taupe_thumbs a, .hawk_black_thumbs a, .falcon_cuoio_thumbs a, .bison_stone_thumbs a, .bison_black_thumbs a").click(function(){ var largePath = $(this).attr("href"); var largeAlt = $(this).attr("title"); $("#viper_stone_img_id, #viper_black_img_id, #titan_cuoio_img_id, #titan_black_img_id, #pheonix_taupe_img_id, #hawk_taupe_img_id, #hawk_black_img_id, #falcon_cuoio_img_id, #bison_stone_img_id, #bison_black_img_id").attr({ src: largePath, alt: largeAlt }); $("h2 em").html(" (" + largeAlt + ")"); return false; }); }); I'v tried adding... Code: <script type="text/javascript"> window.onload = function() { showonly(thechosenone); makeScrollable(wrapper, scrollable); } </script> but im guesing thats not the issue as the problem accurs later in the script? I also tried giving each hidden div its own individual name using the || parameter. Anyone got any clues where iv gone wrong? Its making my head hurt! :-( EDIT: Oh heres the site you can see it all working... http://www.exceedshoes.eu/ Similar TutorialsI am designing a form and basicly what I would like to be able to do is be able to add some more input if a box is checked. A am using an onchange inside the tag to call a function that check if the box is ticked. Then if it is it added another text input using document.write, but there is my problem. The entire page is overwriten, so what I am looking for is another output option that dosn't do that. Any help? Hello, I'm totally new at .js and I'm having an issue with some javascript that seem to overwrite each other.. is there an easy solution to that? I have for example a social slider that doesn't work the way it should because ot the apple trailer .js this is the page: http://www.3backyards.com/3Backyards/index.html is there a simple solution to it? I appreciate any guidance... On a web form my users choose different variables to "shock" (ie change relative to a starting base) over different periods: eg user "shocks" US interest rates 0.50% points above base during 201202-201304 (ie 2012 Quarter2-2013 Quarter4) User may then add another "shock" to same variable: US interest rates .75 % points above base during 201301-201404 (ie 2013 Quarter1-2014 Quarter4) User may then add "shock" to different variable: JAPAN interest rates (RSH_j) 1.00 % points above base during 201201-201404 (ie 2012 Quarter1-2014 Quarter4) I have generated a Select area (ShockVarPlot) that concatenates the required component data from DD boxes for charting: RSH_u,201202-201304,+0.50 RSH_u,201301-201404,+0.75 RSH_j,201301-201404,+1.00 (NB each line of the above Select box is formed after the "Add Shock" button is clicked, so this is the obvious event to trigger the Chart Plot too) For EACH particular variable being shocked (eg RSH_u, RSH_j) I would like to instantly plot the entire profile of each shock. Subsequent shocks to the SAME variable may simply append to earlier shocks or may (partially) overwrite depending if the time period chosen overlaps. But once a NEW shock variable is chosen (eg RSH_j) , the previous plot (of RSH_u) simple gets overwritten in the common plot area. The x-axis scale width can be hard-coded; say 201004-202104. Charting Requirement (for common plot area) ---- "Add Shock" button=> First Plot - Plot RSH_u +0.50 above base over 201202-201304....... "Add Shock" button=> ....then (partially) overwrite/append with +0.75 over 201301-201404 "Add Shock" button=> Second Plot - Delete above plot & Plot RSH_j +1.00 above base over 201301-201404 Chartplot needs to display the variable being charted eg "RSH_u"or "RSH_j" Logic Requirement ---- If new shock => plot this magnitude over selected period within 201001-202104 If new shock (same variable) => plot this as above but this shock overwrites previous if any time-period overlap If new shock (new variable) => delete first plot & plot this magnitude over selected period within 201001-202104 Question -------------- Is there a simple Javascript method to achieve this real-time plotting/appending on clicking "Add Shock" ? I have seen things like FLOT charting but not sure how to read/chart my Listbox output in ShockVarPlot above Any thoughts ? Hi All, I have two scripts which I want to try and integrate. I am using a nice gallery script to show thumbnails which are appended to a an image wrapper which on click of the thumbnail shows the larger image in the image wrapper, I am trying to implement cloud zoom which is a plugin which uses image srcs to then point to an anchor href to show another larger zoom image either in the same place.. which is what I am trying to do or in another div beside. I have had to set me img srcs up in a certain way to easily enter some product details. and I need to try an manipulate the code to make it work to suit my file layout. I am using a var= images [ with a series of file locations and info such as below { src: 'romanticabride/thumbs/tn_Shauna.jpg', srcBig: 'romanticabride/images/Shauna.jpg', title: 'Shauna', longDescription: '<b><H1>Shauna</H1></b><br><b>Romantica Of Devon <br><br><h2>Sizes Available:</h2><br> 6 - 32.<b><br><b><br><b><b><b><H2>Colours Available:</h2><b><br>Various<br>Please Enquire Below<br><br><br><br><a href="mailto:tracy@cherishbridal.co.uk?subject=Web Enquiry Regarding Romantica Shauna Bridal Gown"class="enquiry rose glow" >Click To Enquire About This Item </a>' }, what I need is for cloud zoom to work when the main image wrapper is hovered over which means it will need to add a class or when the whichever srcBig: is hovered over it gets wrapped by href to make the script work . one of my pages is http://www.cherishbridal.co.uk/romaticabride.html the cloud zoom script is at http://www.professorcloud.com/mainsite/cloud-zoom.htm.. I am happy to share a jsfiddle with someone or explain further or post some code. Thank you in advance does any expert know how to pass parameters in the <script ..> tag? for instance; Code: <script type="text/javascript" src="script.js ?param1=val1¶m2=val2&etc "> in the javascript script.js, how would we read the params after the question mark? for example, google this; google shopping cart /v2_2/cart.js I have a script that works in seamonkey(my html editor) but when I use it in IE8 it says errors happen. Here's the code (the first line is on line 7 of the html file): Code: <script type="text/javascript"> function enlarge(imageNum) { var numToString = ""; if(parseInt(imageNum) < 10){ numToString = "0" + imageNum; } else { numToString = imageNum + ""; } window.open("images/LgScreenshot"+numToString+".jpg","Screenshot "+imageNum,"status=0,height=675,width=900,resizable=0"); } </script> And the errors: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB0.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.3; .NET CLR 3.0.30729) Timestamp: Wed, 10 Feb 2010 14:58:16 UTC Message: Object expected Line: 150 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html Message: Invalid argument. Line: 18 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html I need to assign a key in the javascript to actually make the javascript work,. I have a bookmark in chrome , a javascript , which actually works when clicked on it .,. but how can i edit it so that i can actually make it work on click a key or combination of keys. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. Thanks in advance ., Nani On this website: http://evancoleman.net/index.php I really like on the top how the menu has like 5 or 6 icons, and when you hover over them it shows a bubble with the name in them. Does anybody know where I can find this script? Thanks. Hello again . If these questions concerning Regular Expressions are inappropriate in this forum please let me know . Thank You. This expression <script[^>]*>.*?</script> matches ... Code: <script type="text/javascript">var cnnIsHomePage = true;</script> but not ... Code: <script type="text/javascript"> var cnnIsHomePage = true; </script> Please , how can i match the latter ? Hey, I have a forum, and the forum has an rss feed. I want to take the most 10 recent posts from the feed and insert it into my Home page. I have no clue how to do this. At the moment I have been manually entering the posts as you can see here. All the recent posts on the right side of the page are manually entered by me from my forum. Just wondering if anyone could guide me in a direction to do this programmatically. Hi everyone, I just wrote a little noob script and JSL tester says no errors but I think there's some kind of problem.....can you help me fix the problem???? Code: function doattack(baseatk, wepatk, wepcritmax, oppdef, oppdeffactor, oppextradefmax, opphealth, oppname) { var OpponentHealth = opphealth; var OpponentName = oppname; var BaseATK = baseatk; var WeaponATK = wepatk; var WeaponCriticalMax = "100+Math.floor(Math.random()*wepcritmax+1)"; var ActualWeaponATK = "WeaponATK * WeaponCriticalMax / 100"; var OpponentDEF = oppdef; var DEFfactor = oppdeffactor; //defensefactor: used to multiply preoppdef to calculate actualoppdef so more in number the better rmbr that deffactor must be less than 1 var DEFCriticalMax = "100+Math.floor(Math.random()*oppextradefmax+1)"; var PreOpponentDEF = "OpponentDEF * DEFCriticalMax / 100"; var ActualOpponentDEF = "PreOpponentDEF * DEFfactor"; var DamageDone = "BaseATK + ActualWeaponATK"; var OVRDamageDone = "DamageDone * ActualOpponentDEF / 100"; document.write("You just inflicted " + OVRDamageDone + " damage to " + OpponentName + "!" + "<br>"); var NewOpponentHealth = "OpponentHealth - OVRDamageDone"; if (NewOpponentHealth < 0) { document.write(OpponentName + " is dead!" + "<br>"); break; } else { doattack(BaseATK, WeaponATK, WeaponCriticalMax, OpponentDEF, DEFfactor, DEFCriticalMax, NewOpponentHealth, OpponentName); } } doattack(5, 50, 25, 6, 0.22, 10, 200, RedBabyDragon); GREAT THANKS hi, can any tell me that which script they are using?? and plz if u have share it Thanx http://www.nation4all.org/mf/ regards Fawad Hi everyone: I need help taking this pop under script: <script language="JavaScript"> var popunder="URL GOES HERE" function loadpopunder(){ win2=window.open(popunder) win2.blur() window.focus() } loadpopunder() </script> and making it so that I can set it so it only pops up one time and then will not pop up again until after a certain time period. Also, is there a way to make it so it can avoid pop up blockers? Thank you! Quote: function hTools() { var hTools = new Array(6); hTools[0] = "hand tools"; hTools[1] = "saw"; hTools[2] = "hammer"; hTools[3] = "screwdriver"; hTools[4] = "wrench"; hTools[5] = "pliers"; } if(hTools[0] == true) { document.forms[0].item_one.value ="0"; } else if(hTools[1] == true) { document.forms[0].item_one.value ="$20.00" } then I call it fro an onchage selection list Quote: <p><select name ="hTool" onchange ="return hTools();"> <option value ="hTool0">Hand Tool</option> Quote: Item 1: <input type ="text" name ="item_one" My script or my call or both is not working could you please look at it and tell me what I am doing wrong I'm using this javascript on my site, it works perfect. The script changes the background image on the site, just need some mods and I'm no expert. <script language="JavaScript"> <!-- // Copyright 2001 by www.CodeBelly.com // Please do *not* remove this notice. var backImage = new Array(); // don't change this // Enter the image filenames you wish to use. // Follow the pattern to use more images. The // number in the brackets [] is the number you // will use in the function call to pick each // image. // Note how backImage[3] = "" -- which would // set the page to *no* background image. backImage[1] = "/images/bg1.jpg"; backImage[2] = "/images/bg2.jpg" backImage[3] = "/images/bg3.jpg" backImage[4] = "/images/bg4.jpg" backImage[5] = "/images/bg5.jpg" // backImage[4] = ""; this will set to no image // Do not edit below this line. //----------------------------- function changeBGImage(whichImage){ if (document.body){ document.body.background = backImage[whichImage]; } } //--> </script> How Can I set the parameters for the images with the following background-attachment: fixed; background-repeat: no-repeat; background-position: top and make the first image the default background when the site comes up -thanks Eddie i have this Code: VERSION BUILD=6650406 RECORDER=FX TAB T=1 URL GOTO=something.com TAG POS=2 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=NAME:id CONTENT=something1 SET !ENCRYPTION NO TAG POS=2 TYPE=INPUT:PASSWORD FORM=NAME:NoFormName ATTR=NAME:pw CONTENT=something1 SET !ENCRYPTION NO TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:NoFormName ATTR=NAME:pw2 CONTENT=something1 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=NAME:email CONTENT=something@so.com.com TAG POS=1 TYPE=SELECT FORM=NAME:NoFormName ATTR=NAME:year CONTENT=%1964 TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:NoFormName ATTR=VALUE:Register! now what i need is to change the code so the "something" in all CONTENT will change everytime. the math formula would be [x]+1 where x = something so it would end up as something1 ->something2->something3 and so on and on and on any ideas how can i change it? sorry - total javascript newbie over this side of screen Hi there, I'm not too familiar with js, so I'm asking for help I have this script below which loads flash object after clicking fb like button. My question is how to do it after clicking the fb like button automatically to recognize youtube flash object or an object from another tube site? Is it possible? Thank you in advance! Code: <script type='text/javascript'> window.fbAsyncInit = function() { FB.init({appId: "0000000000000", status: true, cookie: true, xfbml: true}); }; (function() { var e = document.createElement("script"); e.async = true; e.src = document.location.protocol + "//connect.facebook.net/en_US/all.js"; document.getElementById("fb-root").appendChild(e); }()); FB.Event.subscribe('edge.create', function(href, widget) { setTimeout("playvideo1();", 0); }); function playvideo1() { document.getElementById('playvideo1').innerHTML = '<object ....... </object>'; } </script> Hello Everyone, Im having trouble at work. They asked me to write a script that will take the 25 first words of a web page and store it to use it later on in the back office of a platform. My problem is i do not know how to get javascript to view 25 words from a site. I wouldnt be able to touch the HTML on the Site. Is this possible? please help Hallo I have a Tag, that i have to change with Javascript. This Tag : Code: <script src=”http://bs.serving- sys.com/BurstingPipe/adServer.bs?cn=sb&c=17&pli=283815&pi=0&w=300&h =250&ncu=$$[your-adserver-clickstring]$$&ord=[timestamp]”></script> <noscript> <a href=”[your-adserver-clickstring]http%3A//bs.serving- sys.com/BurstingPipe/BannerRedirect.asp%3FFlightID%3D283815%26Page%3 D%26PluID%3D0%26Pos%3D5148” target=”_blank”><img src=”http://bs.serving- sys.com/BurstingPipe/BannerSource.asp?FlightID=283815&Page=&PluID=0&P os=5148” border=0 width=300 height=250></a> </noscript> In order to track clicks: Add EASLink= parameters into the redirect string and exchange [timestamp] with _U_. To This Tag: Code: <script src=”http://bs.serving- sys.com/BurstingPipe/adServer.bs?cn=sb&c=17&pli=283815&pi=0&w=300&h =250&ncu=$$EASLink=http://emediate.com$$&ord=_U_”></script> <noscript> <a href=”EASLink=http%3A//bs.serving- sys.com/BurstingPipe/BannerRedirect.asp%3FFlightID%3D283815%26Page%3 D%26PluID%3D0%26Pos%3D5148” target=”_blank”><img src=”http://bs.serving- sys.com/BurstingPipe/BannerSource.asp?FlightID=283815&Page=&PluID=0&P os=5148” border=0 width=300 height=250></a> </noscript> I tried it with this Code, but it wont work, please can someone help me with the script: Code: case "EyeBlaster": HrefRegex = /(<a href=\")/gi; TimestampRegex = /ord=\[.*\]/gi; clickRegex = /ncu=[^&]*/gi; DisplayContainer.value = DisplayContainer.value.replace(TimestampRegex, "ord=_U_"); DisplayContainer.value = DisplayContainer.value.replace(HrefRegex, "EASLink="); if (DisplayContainer.value.match(clickRegex)) { DisplayContainer.value = DisplayContainer.value.replace(clickRegex, "ncu=EASLink="); } else { clickRegex = /ord=/gi; DisplayContainer.value = DisplayContainer.value.replace(clickRegex, "ncu=EASLink=&ord="); } break; Sorry if this isn't JavaScript What would the script be to get something like the image below, when you click the tab, then the picture and headline pops up? Thanks. |