JavaScript - Javascript Simple Question, Calling Div Info On Click (with Example)
Hi,
Im new to javascript so thankyou in advance for reading this! Im trying to create a video gallery, with thumbnails below a main content div, which when clicked display the relevant video in the said div. This isn't a problem and I have managed to do this... However, I also need to display descriptive text (different for every video) in a seperate div, and the first video also needs to autoplay when the page is loaded (rather than waiting until the user requests a video by clicking a thumbnail) I've made an example of where Im at so far and its viewable here... http://www.phixfilm.com/video_thumbn...ideo_test.html The div 'a few lines of info about vid here' is currently just static but this is what i need to change each time a different video is requested by the user (sorry if thats obvious but just in case its not clear) I will be using .movs but I've embedded youtube for now although I don't think that makes any difference... Im presuming it will be a case of having text that is hidden until the thumbnail is clicked...? Which I guess I could do with css but that way seems a little clumsy, I really am a newbie to javascript so a helping hand in the right direction would be very much appreciated. THANKYOU! ps- an example of something similar to what Im trying to achieve is here... http://somesuchandco.com/#670098/Nathalie-Canguilhem Similar TutorialsCode: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 2</title> </head> <SCRIPT LANGUAGE = JavaScript> function estimateHolidays() { var service1; var service2; var service3; var txtGrade; var txtHolidays; var dblEntitlement; var strService; strService = cmbService.value; if (strService == "Service1") { dblEntitlement = 20; } else if (strService == "Service2" && Grade--"1") { dblEntitlement = 24; } else if (strService == "Service2" && Grade--"2") { dblEntitlement = 26; } else if (strService == "Service2" && Grade--"3") { dblEntitlement = 28; } else if (strService == "Service3") { dblEntitlement = 30; } else { dblEntitlement = "Error! Please try again."; } txtHoliday.value = dblEntitlement; } </SCRIPT> <body> <p> <input name="txtGrade" size="25" value="Enter Your Staff Grade"> </p> <p> Years of Service: <select name="cmbService" size="1"> <option value="Service1">Less than 5 years service</option> <option value="Service2">5 to 9 years service</option> <option value="Service3">10 or more years of service</option> </select> </p> <p> <input type="button" value="Estimate Holidays" name="cmdEstimateHolidays" onclick="estimateHolidays()"> </p> <p> Holiday Entitlement: <input name="txtHolidays" size="25"> </p> </body> </html> Why won't this code work!? Its driving me mad. Hello guys, Im new to Javascript,please help me ya in my php code, I retrieve a ID value and assign to variable like below PHP Code: $id = $gettingdata['id']; and I want this id to be include together with javascript "insertsubcat" function like below Code: <a href="javascript:insertsubcat('.$ID.');"/>Click to insert this data</a> in the javascript page, I dont know how to call back the id value and i try like code below but it doesnt work Code: function insertsubcat(data) { var data = data.value; . . . . } Any idea? Thanks Azhan Malaysia Howdy all! Hope Thursday's treatin everybody all right. Way back in the day I did some old school HTML....but after many years not touching a web page I've kind of been thrown straight into the fire with some "wish list" items I'm trying to figure out. I've done plenty of searches and somewhat have an understanding of some of the basics of what I need to do...but I'm not the least bit comfortable with Javascript (I'm just assuming that this the language most applicable to what I'm looking for - please tell me if I'm wrong!) and after the experience of my one day crash course with PHP I knew I needed to turn to some experts. Okay I have a rather large web (about 150 pages) of historical transcriptions created with XHTML (with PHP headers and footers embedded). Generally speaking, I don't much like web pages that have right-click disabled and various other protections in place.....but I'm also the sort to obsessively cite my source material and give proper credits....as a researcher who's hard work has been plagiarized and passed off as the fruits of someone else's labor, I wholly understand why many are inclined to put such walls up. I am aware that there are workarounds to get through almost all such "blocks" - disabling scripts, etc. - and that they serve more as pop-up thought provokers and deterrents to the majority than true security from someone hell-bent on copying the material. Further, I wouldn't want to block an honest researcher from copying/pasting/etc. So this is what I'd wondering... Is it possible to disable right-clicking in a manner that when someone tried, a dialogue/input box with a personal message and request for their name and email address would pop up which (1) would continue to disable right-clicking if "cancel" was chosen rather than the information submitted, (2) would enable right-clicking after they submitted this information - and would keep it enabled until they left the site, and (3) would email me the information. Again, I do know most any solution would be "crackable" and not even show its head to some users...but I think its still worth taking the time to implement...even if it only serves as a thought provoker and appeals to one's conscience. Thanks in advance for any and all help! Brittanie I'm building a webpage using javascript and iframes. Basically I have an iframe in the middle of the index.html page that links to another html page (let's call it iframe.html). My question is, is it possible to call a javascript function from iframe.html to control an object on index.html? If so, how do I do this? I'd like to be able to assign an image in iframe.html with the hyperlink of href="javascript:function()", where the function effects the CSS of a div on index.html. Thanks Hello guys, I'm new to this forum and to Javascript. I need to make a very simple website to check whether a ticket number is valid or not. I have created an array with all the codes necessary, but when I try to loop through it, the only thing that works as it should is the first element of the array. Basically, I want the code to display Correct!, if there is a match between user input and array, or Wrong if otherwise. Here is my code: Code: <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <script type="text/javascript"> function validate() { var list = new Array; list[0]="zDv5BXAc"; list[1]="6YXF3Qwj"; list[2]="k8UKpgwo"; var code= document.getElementById("code"); var name = document.getElementById("name"); for(var i=list.length-1; i>=0; --i) { if (code.value == list[i]) { document.all.confirm.innerHTML = "Correct" } else document.all.confirm.innerHTML = "Wrong" } } </script> </head> <body> <input name="Name" type="text" id="name" size="50"> <input name="Code" type="text" id="code" size="10"> <input name="Check Code" type="submit" value="Verify" onClick="validate()"> <div id="confirm"></div> </body> </html> I'm trying to do some rollover images for a webpage I need to design, for class. I have them set up, and they work.. but the issue is that I set it up in such a way that the .js file is dynamic, and works for each page. You know, so that I don't actually have to specify the images within the .js file. The problem with THAT is that it doesn't automatically load the rollover version of each image, when the page loads.. so it's a bit sluggish. Here's my .js file Code: function swap_image(name,source) { document.images[name].src=source; var argv=swap_image.arguments; if(argv[2] && argv[3] && document.getElementById) { element=document.getElementById(argv[2]); element.innerHTML=argv[3]; } } Here's how I have it in the HTML Code: <a href="gallery" onmouseover="swap_image('gallery','/images/galleryro.jpg')" onmouseout="swap_image('gallery','/images/gallery.jpg')"> <img style = "top:150px; left:100px;" border="0" id="gallery" src="/images/gallery.jpg"/> </a> Is there anything I can do to force it to load the rollover image, without sacrificing my dynamic .js code? I am very new to javascript and really can't figure out what I am doing wrong. I am trying to make a 1 page store that allows you to type in an item and select the color and size you want for that item. If you don't fill in a field, an alert message should tell you that. If all the fields are filled in, a "thank you for purchasing ____________" message should appear in a text area at the bottom of the page. This is my current code: Code: <html> <head> <script> function processform() { if ( document.form1.item1.value == "") { alert("No Item Chosen") } else { chosen = "" len = document.form1.c1.length for (i = 0; i <len; i++) { if (document.form1.c1[i].checked) { chosen = document.form1.c1[i].value } } if (chosen == "") { alert("No Color Chosen") } } else { itemname = document.form1.item1.value; itemcolor = document.form1.c1.value; itemsize = document.form1.size.value; document.form1.txtarea1.value = "Thank you for purchasing a " + itemsize + " " + itemcolor + " " + itemname; } } </script> </head> <body> <h1>Store</h1> <br/><br/> <form name="form1"> <h4>What item would you like to buy?</h4> <input type="text" name="item1" value="" /><br /> <br/><br/> <h4>Color</h4> <input type="radio" name="c1" value="blue" /> Blue<br /> <input type="radio" name="c1" value="red" /> Red<br /> <input type="radio" name="c1" value="green" /> Green<br /> <input type="radio" name="c1" value="yellow" /> Yellow<br /> <br/><br/> <h4>Size</h4> <select name="size"> <option value="small">Small</option> <option value="medium">Medium</option> <option value="large">Large</option> <option value="extra large">Extra Large</option> </select> <br/><br/> <button onclick="processform()">Purchase</button> <br/><br/> <textarea rows="2" cols="40" name = "txtarea1"> </textarea> </form> </body> </html> When I press the purchase button, no alert message is shown, nor does anything get displayed in the textarea. What am I doing wrong? I need to be able to drag an image from one browser window to a form text input in a different window, populating it with the image file name. I can do this easily, except that the result is the whole url, and I only want the filename to be inserted. In other words, it inserts http://www.path/path/file.jpg, but I just want to end up with file.jpg. I believe the file object .name property holds the info I need, but I don't know how to populate the input field with it. Any help appreciated. I have two pages one html page and one Javascript page index.html and script.js. I want to call the javascript page 3 times to display 3 images. How would I do this from my html page. script.js Code: <script language="JavaScript"> <!-- /* Random Image Link Script By Website Abstraction (http://www.wsabstract.com) and Java-scripts.net (http://www.java-scripts.net) */ function random_imglink(){ var myimages=new Array() //specify random images below. You can have as many as you wish myimages[1]="http://flashmajic.com/Google/atomica/atomicasmallicon.jpg" myimages[2]="http://flashmajic.com/Google/atomica/atomicasmallicon.jpg" myimages[3]="http://flashmajic.com/Google/atomica/atomicasmallicon.jpg" //specify corresponding links below var imagelinks=new Array() imagelinks[1]="http://www.wsabstract.com" imagelinks[2]="http://www.dynamicdrive.com" imagelinks[3]="http://www.java-scripts.net" var ry=Math.floor(Math.random()*myimages.length) if (ry==0) ry=1 document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=2 hspace=1></a>') } random_imglink() //--> </script> index.html 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>Untitled Document</title> </head> <body> ????? How would I call that script 3 times to display 3 random images? </body> </html> Hi there I am wondering if anyone can tell me the best way to access the functions of an Iframe from the parent of the frame. I have tried Code: var myFrame = document.getElementById('gigmap'); myFrame.flashMouseover(gid); and Code: window.frames['gigmap'].document.flashMouseover(gid); though these didn't work. Basically this is what i want: Mainpage function a(id) receives flash variable 'id' then sends variable 'number' to iframe function b(id) . The part in red is where I have the problem. In case you are wondering what I am doing is sending an id of a gig in my database when its button rolled over in a flash swf to a Google Map (using Google maps javascript API inside the Iframe 'gigmap) and make the corresponding marker on the map jump. I have it so the iframed map markers send to the flash file on rollover though not the other way round...yet! Hello guys, Is there any way I can get the number of 'CPBucks' from this piece of HTML, It's currently at 1 but it will change. Code: <div class="user-info"> <img src="http://illiweb.com/fa/punbb/online.png" id="i_icon_online" alt="Online" title="Online"><br> <span style="white-space:nowrap;"><span style="color:##66666;">Posts</span>: </span>2<br> <span style="white-space:nowrap;"><span style="color:##66666;">CPBucks</span>: </span>1<br> <span style="white-space:nowrap;"><span style="color:##66666;">Join date</span>: </span>2011-10-11<br> </div> Thanks in HTML you can call CSS Code: <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <tr><td class="cssHere">Display</td></tr> can you even call CSS in javascript? Code: document.writeln("<tr><td class="cssHere">" + Display + "</td></tr>"); if so how do you even call the "style.css" thanks Hello, I am new to using Javascript and have some experience with HTML and CSS. I am trying to use Javascript to display an image based on a value. I have the image positions in my .css. Just to make it easy if my var x=0 i want to call the "position 1" div, or else i want to call the "position 2" div. How can i make this possible. I have positions because i have a background image and i want the different pictures to be in a different location on the background based on the value. Below is my code that I have right now. Thanks for the help. layout.css #layout { position: relative; top:0%; z-inderx:-1; } #date { position: absolute; top:5%; left: 50%; margin-left: -190px; z-index: 1; font-family: calibri; font-size: 44px; font-weight: bold; color:#000000; } #location1 { position: absolute; top:22%; left: 50%; margin-left: -590px; z-index: 1; } #location2 { position: absolute; top:28%; left: 50%; margin-left: -590px; z-index: 1; } Layout.HTML <html> <head> <Title>Layout</title> <link rel"stylesheet" type="text/css" href="layout.css" /> </head> <body> <div id="layout"> <center> <img border="0" src="background.png" width="1200" height="880" /> </center> </div> <div id="date"> 24 OCTOBER </div> <script type="text/javascript"> var x=0; if (x==0) { <div id="location1"> <img border="0" src="picture1.png" width="70" height="60" /> </div> } else { <div id="location2"> <img border="0" src="picture2.png" width="70" height="60" /> </div> } </script> </body> </html> Hi everyone! Firstly, im a beginner in Javascript, totally noobie. Much why this is posted! I have found this site: http://www.forswor.com/index.php/data-apis/ And I want to use this to post the server status on my forum/website. How exactly do I do that? I know there are examples and such and I have read and read on that page but I cannot figure out how to do this. I cant just paste: <script type="text/javascript" src="http://www.forswor.com/forswor_services/prod/serverwidget/getSWTORStatusjs.php"> </script> How would I get this to show the information of say for example Bloodworthy server and in text? I tried adding the line document.write(forswor_server_name);, but didnt show up anything - stupid as I am obviously I have no clue what im doing. I can manage html\css and some php but this is new for me, hehe. Thank you so much for reading an idiots post! Most regards, me. Hi, I'm have set up a gallery site, pretty standard stuff with thumbnails to the right and big image to the left. I would like to add a fade in on the big image when the thumbnail is clicked and don't really know how to implement it. The big images are contained in a div called <#left> while the thumbs are within a div called <div class="gallery"> I have searched Google and these forums for a solution but haven't had any luck...can anyone help me out with this? Thanks J hi i have a sliding vertical menu in my page in the left side and in the right side i have a text say for eg: Home. So when i click on home, i need the left side vertical menu to slide and open and the home in the left side should get highlighted. How do i do this in javascript ???? Pls help!!!! I would like to add some javascript code that used for mobile browser detection to redirect page to another page. I would like to add it to content editor web part in sharepoint. I think I need to add it to the source editor. I got the following javascript code from a website. (function(a,b){if(/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris| kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo| up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1- 6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te| us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa| cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el (49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w| od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\- (20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( | \/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/| ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50| p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok (6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po (ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/| sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl (45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg \-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk (40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)| wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))window.location=b}) (navigator.userAgent||navigator.vendor|| window.opera,'http://www.mycustomizedmobilepage.html'); {/script} I also learned that I need to add this line of code to the page: _spBodyOnLoadFunctionNames.push("functionName"); to call the javascript so that there is some kind of time delay to make the page upload to work correclty with the code. My question is: I see this javascript start with function(a,b), I did't see actually a function name, how can I call this function by using _spBodyOnLoadFunctionNames.push Thanks -------------------------------------------------------------------------------- var macs = { getMacAddress : function() { document.macaddressapplet.setSep( "-" ); document.write( "Mac Address = " + document.macaddressapplet.getMacAddress() ); } how do i call this function and display out in the website? this doesn't seems working.. <script type="text/javascript"> document.write(mac.getMacAddress()); </script> Anyone help? Hello all here is a more intelligent question. This one is just on an exercise I am doing. I have to call a function using parameter values. my main function is this Code: function showResults(race,name,party,votes) or just function showResults in the next lines below i have to call the function is this the right way Code: <script type="text/javascript"> { showResults=("race[0],name1,party1,votes1"); } </script> or should it be without the { and } like this? Code: script type="text/javascript"> showResults=("race[0],name1,party1,votes1"); </script> or is it like this Code: script type="text/javascript"> showResults(race[0],name1,party1,votes1); </script> Thanks all, what would be the proper method Thanks Hi, I currently have a asp.NET page which has a textbox with the ID: "txtbox1" I would like javascript to store the data entered into txtbox1 into a var. I have tried using var jVarName; jVarName = '<%#aVarName%>'; but so far it hasnt worked. Any suggestions would be appreciated ^^ |