JavaScript - Javascript Problem, Id's And Button's Control.
Hello, i am doing a test right now.
What i have done is 1. A Counter/Timer That Counts until Zero 2. A Button that appears when the counter is Zero When I Click the Button it executes this code in the address bar (Navigates): javascript:gonow(); The id of the Timer: count What i want? When the Button appears, it will be clicked automatically... i started doing a different code, when the timer = 0 to navigate at javascript:gonow(); but it didnt worked.... See my code he Code: function AutoClick(){ var timer = document.getElementById(count); if(timer.value=0) unsafewindow.gonow(); } Tried to explain as more as i could, now im waiting for an answe, dont dissapoint me please. Similar TutorialsHello, I am trying to build a jukebox online. I use a quicktime plugin, the reason for this is that windows media player wouldnt work in firefox. I can now work the plugin with javascript to make it stop play pause and fast forward to a song, thing is i cant make it to play another song. in all sources i looked at , this piece of code should be what i am looking for : document.getElementById('movie2').SetQTNEXTUrl(2,'music/myparty.mp3'); well, that in any case wont work for me, then there was another piece of code wich should go in the embed part wich is this: QTNEXT1=myparty.mp3 in firefox it has the effect of opening the myparty.mp3 on another page in wich the quicktime plugin will show but cant find the song, in internet explorer it just simply give's the error "page is ready but with errors". can anyone help me to understand what goes wrong, what would fix it or a simpler way to embed a large amount of songs onto a website? hoping to hear something soon this is the 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> <SCRIPT LANGUAGE = "JavaScript"> function PlayIt(movname) { movname.Play(); } function StopIt(movname) { movname.Stop(); } function rewindIt(movname) { movname.rewind(); } function SetRate(movname,rate) { movname.SetRate(rate); } function SetTime(movname,time) { movname.SetTime(time); } function VolumeIt(movname,v) { movname.SetVolume(v); } document.getElementById('movie2').SetQTNEXTUrl(2,'music/myparty.mp3'); document.getElementByName('movie2').SetQTNEXTUrl(2,'music/myparty.mp3'); document.getElementById('movie2').SetQTNEXTUrl(1,'music/myparty.mp3'); document.getElementByName('movie2').SetQTNEXTUrl(1,'music/myparty.mp3'); </SCRIPT> </head> <body> <embed hidden="false" autostart="true" loop="-1" controls="largeconsole" height="25" width="100"></embed> <body> <br><br> <a href="#" onClick="StartVideo()" ;>startvideo</a><br> <a href="#" onClick="PlayIt(movie2)";>functie</a><br> <a href="javascript:document.movie2.Stop()">Stop</a><br> <a href="javascript:document.movie2.Play()">Play</a><br> <a href="javascript:document.movie2.SetRate(1.0);">SetRate(1.0)</a><br> <a href="javascript:document.movie2.SetRate(2.0);">SetRate(2.0)</a><br> <a href="javascript:document.movie2.SetVolume(100);"> SetVolume(100) </a><br> <a href="javascript:document.movie2.SetVolume(255);"> SetVolume(255) </a><br> <br> <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="180" height="160" id="movie2"> <param name="src" value="music/camaro.mp3"> <param name="Autoplay" value="false"> <embed width="180" height="160" src="music/camaro.mp3" QTNEXT1=myparty.mp3 name="movie2" enablejavascript="true" autostart="false"> </object> <br> <SCRIPT LANGUAGE = "JavaScript"> document.getElementById('movie1').SetQTNEXTUrl(2,'music/myparty.mp3'); document.getElementByName('movie1').SetQTNEXTUrl(2,'music/myparty.mp3'); document.getElementById('movie2').SetQTNEXTUrl(2,'music/myparty.mp3'); document.getElementByName('movie2').SetQTNEXTUrl(2,'music/myparty.mp3'); </SCRIPT> <br> <br> http://userwww.sfsu.edu/~infoarts/te...avascript.html </body> </html> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Good day all, I was hoping someone could help me out with the following. I currently have a slideshow that as thumbnails under a main image. The thumbnails slide left and right with hover on a button and with a click changes main image without any problems. Few things I am looking to change/add: 1. The ability to mouse over the main image and have the caption appear than disappear when the mouse is moved off. Currently I have the caption as a static text under the main image. 2. Start the thumbnail position in the middle instead of the left 3. Add mouseover buttons to the main image to give the ability to cycle through the images instead of having to always use the thumbnails. Below I've include the Javascript code: Is this the best way or is there a better way? Example of slideshow: http://neileverosborne.com/portfolios/manatees.html JAVASCRIPT: Code: var displayWaitMessage=true; // Display a please wait message while images are loading? var activeImage = false; var imageGalleryLeftPos = false; var imageGalleryWidth = false; var imageGalleryObj = false; var maxGalleryXPos = false; var slideSpeed = 0; var imageGalleryCaptions = new Array(); function startSlide(e) { if(document.all)e = event; var id = this.id; if(this.id=='arrow_right'){ slideSpeedMultiply = Math.floor((e.clientX - this.offsetLeft) / 5); slideSpeed = -1*slideSpeedMultiply; slideSpeed = Math.max(-10,slideSpeed); }else{ slideSpeedMultiply = 10 - Math.floor((e.clientX - this.offsetLeft) / 5); slideSpeed = 1*slideSpeedMultiply; slideSpeed = Math.min(10,slideSpeed); if(slideSpeed<0)slideSpeed=10; } } function releaseSlide() { var id = this.id; slideSpeed=0; } function gallerySlide() { if(slideSpeed!=0){ var leftPos = imageGalleryObj.offsetLeft; leftPos = leftPos/1 + slideSpeed; if(leftPos>maxGalleryXPos){ leftPos = maxGalleryXPos; slideSpeed = 0; } if(leftPos<minGalleryXPos){ leftPos = minGalleryXPos; slideSpeed=0; } imageGalleryObj.style.left = leftPos + 'px'; } setTimeout('gallerySlide()',20); } function showImage() { if(activeImage){ activeImage.style.filter = 'alpha(opacity=50)'; activeImage.style.opacity = 0.5; } this.style.filter = 'alpha(opacity=100)'; this.style.opacity = 1; activeImage = this; } function initSlideShow() { document.getElementById('arrow_left').onmousemove = startSlide; document.getElementById('arrow_left').onmouseout = releaseSlide; document.getElementById('arrow_right').onmousemove = startSlide; document.getElementById('arrow_right').onmouseout = releaseSlide; imageGalleryObj = document.getElementById('theImages'); imageGalleryLeftPos = imageGalleryObj.offsetLeft; var galleryContainer = document.getElementById('galleryContainer'); imageGalleryWidth = galleryContainer.offsetWidth - 20; maxGalleryXPos = imageGalleryObj.offsetLeft; minGalleryXPos = imageGalleryWidth - document.getElementById('slideEnd').offsetLeft; if (navigator.userAgent.indexOf('MSIE') >= 0) { var arrowWidth = document.getElementById('arrow_left').offsetWidth; var el = document.createElement('div'); el.style.position = 'absolute'; el.style.left = arrowWidth + 'px'; el.style.width = (galleryContainer.offsetWidth - arrowWidth * 2) + 'px'; el.style.overflow = 'hidden'; el.style.height = '100%'; document.getElementById('galleryContainer').appendChild(el); el.appendChild(document.getElementById('theImages')); } var slideshowImages = imageGalleryObj.getElementsByTagName('IMG'); for(var no=0;no<slideshowImages.length;no++){ slideshowImages[no].onmouseover = showImage; } var divs = imageGalleryObj.getElementsByTagName('DIV'); for(var no=0;no<divs.length;no++){ if(divs[no].className=='imageCaption')imageGalleryCaptions[imageGalleryCaptions.length] = divs[no].innerHTML; } gallerySlide(); } function showPreview(imagePath,imageIndex){ var subImages = document.getElementById('previewPane').getElementsByTagName('IMG'); if(subImages.length==0){ var img = document.createElement('IMG'); document.getElementById('previewPane').appendChild(img); }else img = subImages[0]; if(displayWaitMessage){ document.getElementById('waitMessage').style.display='inline'; } document.getElementById('largeImageCaption').style.display='none'; img.onload = function() { hideWaitMessageAndShowCaption(imageIndex-1); }; img.src = imagePath; } function hideWaitMessageAndShowCaption(imageIndex) { document.getElementById('waitMessage').style.display='none'; document.getElementById('largeImageCaption').innerHTML = imageGalleryCaptions[imageIndex]; document.getElementById('largeImageCaption').style.display='block'; } window.onload = initSlideShow; I have a simple js script which toggles between 2 tabs using a simple switch function to display: block or none. In each tab I have a form which returns data from a db using php mysql. The problem is that when I click the submit button the page is reloaded and so the page reverts to showing the 1st tab. The data is returned correctly but the users has to click the 2nd tab to view it. I have tried adding on onclick event to the submit button but this doesn't work. Is it possible to force the 2nd tab to show if the submit button in the 2nd tab is clicked. Many thanks! All, I have some code on my page which changes images in a div without reloading the page. This works great, however my problem comes with I go through a couple images and the actual URL is still on the original image. Is there any way to change the URL when I click the image as well?? Thanks in advance. Hi, Ok i want to do the following... I am using blogger and I have thousands of posts and each post topic has a specific image assigned to it but every now and then I like to change the image that is being displayed but then I have to go through thousands of posts to change the image URL and this takes super long to complete. I thought of an idea of using Javascript to control this so I need your help please.. I want to be able to have a JS that I can insert the URL's of each image required for the posts and assign an ID like a number or a name to them, then have a seperate JS script that I can insert in ALL my posts and assign the same number to each related post relating to the image ID... So if I need to change images then all I need to do is change the URL in the Javascript and it affects all the posts that contain this image... hope this makes sense.. Please help Thank you. I have seen code like this but it only randomizes the images but is the same concept, perhaps someone can just alter this code for me please... [CODE] <head> <script language="JavaScript"> <!-- var theImages = new Array() theImages[0] = 'http://lh5.ggpht.com/_MAclvGBXzj4/TEtvnlxvvrI/AAAAAAAABQw/N7UVoBvtjxU/s320/video34.png' theImages[1] = 'http://lh6.ggpht.com/_MAclvGBXzj4/TEIZlr5FE6I/AAAAAAAABKU/LoBdw7Kqf3w/s200/Inside-blogger-256.png' theImages[2] = 'http://3.bp.blogspot.com/_MAclvGBXzj4/TCHDY788QaI/AAAAAAAAAAU/SnWr-NP0dqE/s200/news.png' theImages[3] = 'http://3.bp.blogspot.com/_MAclvGBXzj4/TEwgs_hhcXI/AAAAAAAABQ4/JTX1mzmdQLU/s200/croatia-flag.GIF' theImages[4] = 'http://lh6.ggpht.com/_MAclvGBXzj4/TEtzAvpIEQI/AAAAAAAABQ0/RiLAfiUsCiA/s320/warning23.png' 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('<img src="'+theImages[whichImage]+'">'); } //--> </script> </head> <body> <script language="JavaScript"> <!-- showImage(); </script> </body> [CODE] Hi all, How can I insert ads on html5 video tag before the main video plays? Now, I need make a sample allow: - play first advertisment video - play second ad video - play main video after 10 mins (half of duration) . pause main video . and play ad video. after that. continue the main video playback. Can you help me please? Thank you very much! Hello friends... i am working on the healthcare project.In which there are user interactive pages such as registration page,profile page. In registration page to register the portal the birth date of user is required . so i have added the calendar control using javascript. I want that whenever user clicks on the calendar the birth date is displayed in the textfield. but it cannot displayed the birth date... So please tell me the sloution... following is the code for calendar control <p> <meta content="text/html;" http-equiv="Content-Type" /> <style type="text/css"> #calender { width: 200px; font-family: ms sans serif, sans serif; font-size: 7pt; } #calenderTable { border-style: outset; border-width: 2px; border-color: black; background-color: #EEE; display: none; position: absolute; z-index: 1; top: 0px; left: 0px; } #calenderTableHead TR { background-color: #5FB404; } #calenderTableDays TR { background-color: #B40404; color: #E6E6E6; } .normalDay { border: 1px dotted black; cursor: pointer; } .hlDay { border: 1px black; background-color: #585858; color: #E6E6E6; cursor: pointer; } .toDay { border: 1px solid #E70; background-color: #FD8; color: #E70; font-weight: bold; cursor: pointer; } .choosenDay { border: 1px #000000; background-color: #585858; color: #E6E6E6; font-weight: bold; cursor: pointer; } </style> <link rel="stylesheet" type="text/css" href="calendar.css" /> <script language="javaScript" type="text/javascript" src="calendar.js"> // Array of max days in month in a year and in a leap year monthMaxDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; monthMaxDaysLeap= [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; hideSelectTags = []; function getRealYear(dateObj) { return (dateObj.getYear() % 100) + (((dateObj.getYear() % 100) < 39) ? 2000 : 1900); } function getDaysPerMonth(month, year) { /* Check for leap year. These are some conditions to check year is leap year or not... 1.Years evenly divisible by four are normally leap years, except for... 2.Years also evenly divisible by 100 are not leap years, except for... 3.Years also evenly divisible by 400 are leap years. */ if ((year % 4) == 0) { if ((year % 100) == 0 && (year % 400) != 0) return monthMaxDays[month]; return monthMaxDaysLeap[month]; } else return monthMaxDays[month]; } function createCalender(year, month, day) { // current Date var curDate = new Date(); var curDay = curDate.getDate(); var curMonth = curDate.getMonth(); var curYear = getRealYear(curDate) // if a date already exists, we calculate some values here if (!year) { var year = curYear; var month = curMonth; } var yearFound = 0; for (var i=0; i<document.getElementById('selectYear').options.length; i++) { if (document.getElementById('selectYear').options[i].value == year) { document.getElementById('selectYear').selectedIndex = i; yearFound = true; break; } } if (!yearFound) { document.getElementById('selectYear').selectedIndex = 0; year = document.getElementById('selectYear').options[0].value; } document.getElementById('selectMonth').selectedIndex = month; // first day of the month. var fristDayOfMonthObj = new Date(year, month, 1); var firstDayOfMonth = fristDayOfMonthObj.getDay(); continu = true; firstRow = true; var x = 0; var d = 0; var trs = [] var ti = 0; while (d <= getDaysPerMonth(month, year)) { if (firstRow) { trs[ti] = document.createElement("TR"); if (firstDayOfMonth > 0) { while (x < firstDayOfMonth) { trs[ti].appendChild(document.createElement("TD")); x++; } } firstRow = false; var d = 1; } if (x % 7 == 0) { ti++; trs[ti] = document.createElement("TR"); } if (day && d == day) { var setID = 'calenderChoosenDay'; var styleClass = 'choosenDay'; var setTitle = 'this day is currently selected'; } else if (d == curDay && month == curMonth && year == curYear) { var setID = 'calenderToDay'; var styleClass = 'toDay'; var setTitle = 'this day today'; } else { var setID = false; var styleClass = 'normalDay'; var setTitle = false; } var td = document.createElement("TD"); td.className = styleClass; if (setID) { td.id = setID; } if (setTitle) { td.title = setTitle; } td.onmouseover = new Function('highLiteDay(this)'); td.onmouseout = new Function('deHighLiteDay(this)'); if (targetEl) td.onclick = new Function('pickDate('+year+', '+month+', '+d+')'); else td.style.cursor = 'default'; td.appendChild(document.createTextNode(d)); trs[ti].appendChild(td); x++; d++; } return trs; } function showCalender(elPos, tgtEl) { targetEl = false; if (document.getElementById(tgtEl)) { targetEl = document.getElementById(tgtEl); } else { if (document.forms[0].elements[tgtEl]) { targetEl = document.forms[0].elements[tgtEl]; } } var calTable = document.getElementById('calenderTable'); var positions = [0,0]; var positions = getParentOffset(elPos, positions); calTable.style.left = positions[0]+'px'; calTable.style.top = positions[1]+'px'; calTable.style.display='block'; var matchDate = new RegExp('^([0-9]{2})-([0-9]{2})-([0-9]{4})$'); var m = matchDate.exec(targetEl.value); if (m == null) { trs = createCalender(false, false, false); showCalenderBody(trs); } else { if (m[1].substr(0, 1) == 0) m[1] = m[1].substr(1, 1); if (m[2].substr(0, 1) == 0) m[2] = m[2].substr(1, 1); m[2] = m[2] - 1; trs = createCalender(m[3], m[2], m[1]); showCalenderBody(trs); } hideSelect(document.body, 1); } function showCalenderBody(trs) { var calTBody = document.getElementById('calender'); while (calTBody.childNodes[0]) { calTBody.removeChild(calTBody.childNodes[0]); } for (var i in trs) { calTBody.appendChild(trs[i]); } } function setYears(sy, ey) { // current Date var curDate = new Date(); var curYear = getRealYear(curDate); if (sy) startYear = curYear; if (ey) endYear = curYear; document.getElementById('selectYear').options.length = 0; var j = 0; for (y=ey; y>=sy; y--) { document.getElementById('selectYear')[j++] = new Option(y, y); } } function hideSelect(el, superTotal) { if (superTotal >= 100) { return; } var totalChilds = el.childNodes.length; for (var c=0; c<totalChilds; c++) { var thisTag = el.childNodes[c]; if (thisTag.tagName == 'SELECT') { if (thisTag.id != 'selectMonth' && thisTag.id != 'selectYear') { var calenderEl = document.getElementById('calenderTable'); var positions = [0,0]; var positions = getParentOffset(thisTag, positions); // nieuw var thisLeft = positions[0]; var thisRight = positions[0] + thisTag.offsetWidth; var thisTop = positions[1]; var thisBottom = positions[1] + thisTag.offsetHeight; var calLeft = calenderEl.offsetLeft; var calRight = calenderEl.offsetLeft + calenderEl.offsetWidth; var calTop = calenderEl.offsetTop; var calBottom = calenderEl.offsetTop + calenderEl.offsetHeight; if ( ( /* check if it overlaps horizontally */ (thisLeft >= calLeft && thisLeft <= calRight) || (thisRight <= calRight && thisRight >= calLeft) || (thisLeft <= calLeft && thisRight >= calRight) ) && ( /* check if it overlaps vertically */ (thisTop >= calTop && thisTop <= calBottom) || (thisBottom <= calBottom && thisBottom >= calTop) || (thisTop <= calTop && thisBottom >= calBottom) ) ) { hideSelectTags[hideSelectTags.length] = thisTag; Tag.style.display = 'none'; } } } else if(thisTag.childNodes.length > 0) { hideSelect(thisTag, (superTotal+1)); } } } function closeCalender() { for (var i=0; i<hideSelectTags.length; i++) { hideSelectTags[i].style.display = 'block'; } hideSelectTags.length = 0; document.getElementById('calenderTable').style.display='none'; } function highLiteDay(el) { el.className = 'hlDay'; } function deHighLiteDay(el) { if (el.id == 'calenderToDay') el.className = 'toDay'; else if (el.id == 'calenderChoosenDay') el.className = 'choosenDay'; else el.className = 'normalDay'; } function pickDate(year, month, day) { month++; day = day < 10 ? '0'+day : day; month = month < 10 ? '0'+month : month; if (!targetEl) { alert('target for date is not set yet'); } else { targetEl.value= day+'-'+month+'-'+year; closeCalender(); } } function getParentOffset(el, positions) { positions[0] += el.offsetLeft; positions[1] += el.offsetTop; if (el.offsetParent) positions = getParentOffset(el.offsetParent, positions); return positions; } </script> <link rel="stylesheet" type="text/css" href="calendar.css" /></p> <form> <input name="datum1" type="text" /><a onClick="setYears(1900, 2020); showCalender(this, 'datum1');" href="#"> <img alt="" width="17" height="13" src="/image/image_gallery?uuid=ad0e28d1-ae91-4535-a558-32d62a7df92e&groupId=10136&t=1294233035464" /></a> </form> <!-- Calender Script --> <table id="calenderTable"> <tbody id="calenderTableHead"> <tr> <td colspan="4" align="center"><select id="selectMonth" onChange="showCalenderBody(createCalender(document.getElementById('selectYear').value, this.selectedIndex, false));"> <option value="0" selected="selected">Jan</option> <option value="1">Feb</option> <option value="2">Mar</option> <option value="3">Apr</option> <option value="4">May</option> <option value="5">Jun</option> <option value="6">Jul</option> <option value="7">Aug</option> <option value="8">Sep</option> <option value="9">Oct</option> <option value="10">Nov</option> <option value="11">Dec</option> </select></td> <td colspan="2" align="center"><select id="selectYear" onChange="showCalenderBody(createCalender(this.value, document.getElementById('selectMonth').selectedIndex, false));"></select></td> <td align="center"><a onClick="closeCalender();" href="#"><font color="#003333" size="+1">X</font></a></td> </tr> </tbody> <tbody id="calenderTableDays"> <tr> <td>Sun</td> <td>Mon</td> <td>Tue</td> <td>Wed</td> <td>Thu</td> <td>Fri</td> <td>Sat</td> </tr> </tbody> <tbody id="calender"> </tbody> </table> <!-- End Calender Script --> Thanking you... Hello Friends... I am working on the healthcare project.So in that project there are different html pages for the user interaction & Events,such as user registration,patient profiles,doctor registration. So in the patient registration page i want to add the calendar control the requirement is whenever i click on the calendar control the user selected date is displayed in the textbox in the ddmmyyyy format.. So please tell me the answer... Thanking you..... Umesh I have an ASP.Net page that uses functions in a .js file. I'm trying to reset the values in the controls on the form. The script I'm using works for Text boxes, TextArea boxes, and Check boxes, but, doesn't work for Select-One (DropDownList) or Select-Multi (List) controls. Included is the code. I use the alert() call as troubleshooting to insure the code segment is entered and the control is identified. The SelectIndex of the control is not being set. When this code is hard coded on the page it works. Code: function ClearAllControls() { for (i = 0; i <= document.forms[0].length; i++) { doc = document.forms[0].elements[i]; switch (doc.type) { case 'text':doc.value = ''; break; case 'textarea':doc.value = ''; break; case 'checkbox':doc.checked = false; break; case 'select-one': doc.selectedindex = 0; alert(doc.name + " - " + doc.type) break; default:break;} } } Hi. I'll would like to know how can I control a swf with a FLVPlayback, that it's reading a movie from my server, with Javascript. check the link. it's the second image http://www.luisporem.com/projects/pr...nto_glass.html does anyone knows how? thanks Firstly let me say, im relatively new to Javascript so im still picking things up.. I have a website that i want to add several mp3's onto. When a user clicks a link i wanted to make javascript change the streaming audio to the one that was selected. My HTML is as follows.. Code: <table style="background-color:Black; color:gold; font-weight:700; font-size:16px"> <tr onClick="Click('http://www.m-hops.co.uk/Music/Motown Flavours.mp3')"><td> 1. Motown Flavours </td></tr> <tr onClick="Click('http://www.m-hops.co.uk/Music/All_Around_The_World.mp3')"><td> 2. All Around The World </td></tr> <tr><td> <OBJECT ID="MediaPlayer" WIDTH="290" HEIGHT="50" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" STANDBY="Loading Windows Media Player components..." TYPE="application/x-oleobject"> <PARAM id="TRACK" name="FileName" value="http://www.m-hops.co.uk/Music/Motown Flavours.mp3"> <PARAM name="autostart" value="true"> <PARAM name="ShowControls" value="true"> <param name="ShowStatusBar" value="true"> <EMBED id="sound" TYPE="application/x-mplayer2" src="" NAME="MediaPlayer" WIDTH="290" HEIGHT="50" ShowControls="1" ShowStatusBar="1" autostart="1"> </EMBED> </OBJECT> </td></tr> </table> and my Javascript is.. Code: <script language="javascript" type="text/javascript"> function Click(track) { document.getElementById('TRACK').value = track; window.alert(document.getElementById('TRACK').value); } </script> It appears that the right track is being parsed to the javascript but its not changing the audio thats being played. Any ideas?? Hi All, I have a select html control as below ; <SELECT > <OPTION VALUE="1"> This is option 1 </OPTION> <OPTION VALUE="2" >This is option 2 </OPTION> <OPTION VALUE="3" >This is option 3 </OPTION> </SELECT> My requirement is that when user moves pointer over the items the value of the item should be shown in a hint box. How could I show the value of the item in a hint box as user moves pointer over an item using javascript? Thanks, Dev This is a question more about an ASP.NET web application, but javascript is involved, so I'm hoping some javascript gurus can assist me. I'm working with a web application that needs to get access to an ASP.NET web control (a button) in javascript. The problen is that since the control is run on the server, javascript can't access it in the standard way (i.e. document.getElementById(controlId); ). I've actually solved this problem before in a different application, but my solution there doesn't seem to work here for some reason. I have this in an aspx file: Code: <script...> ... function myfun() { var b = document.getElementById("<%=SaveButton.ClientID%>"); alert(b); } </script> ... <asp:Button ID="SaveButton" Text="save" OnClientClick="myfun()" ClientIDMode="Static" runat="server" UseSubmitBehavior="False" /> I have a designer class in which the button is declared (and therefore exists in the server-side codebehind): Code: protected global::System.Web.UI.WebControls.Button SaveButton; But when I click on my button, the alert box says "null". Why am I not able to get my button in the javascript function? Some things to note: *The button exists within a content tag: Code: <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> *I'm working within Visual Studios 2008. Hi, Is it possible that when a webpage loads I can have javascript change the class of a div from: .up { transform: translate(0px,-500px) transition: all 5s ease-in; } to .down { transform: translate(0px,0px) transition: all 5s ease-in; } Essentially I would like a div to move down into place from the top of screen to the middle of screen after the page has loaded. Some thing like this?: Code: <script type="text/javascript"> function transform() { document.getElementById("content").className = "down"; </script> <div id="content" class "up" onload="transform()"> </div> </html> would this work or is there a better way? Adrian. Help will be greatly appreciated! Situation: I have a very long page divided into many sections vertical-wise marked by bookmarks, say pageX.html#s1 to s10. I need to show the section inside an iframe (iFrame1) on the mainpage (mainpage.html). I am thinking of having 4 buttons, sitting on the mainpage, to help navigate between these sections on pageX, namely NEXT, PREVIOUS, TOP, END. condition of the frame, fixed width/height, no scroll, no border. Very new to javascript but need this code to make a page work for BIZ. Thank you in advance for anyone kind enough to point the right direction! Hello everyone, I have a problem with the control of my two forms principle it is good for the first form, but if I wanted to control my 2nd form, blocking ca Here's the script: Code: <html> <head> <script type="text/javascript" > function formValidation1(oEvent) { oEvent = oEvent || window.event; var txtField = oEvent.target || oEvent.srcElement; var txt_nom_pereck1=true; var msg=" "; if(document.getElementById("txt_nom_pere").value.length < 3 ){ txt_nom_pereck1=false; msg = msg + "Your name should be minimun 3 char length";} if(document.getElementById("txt_prenom_pere").value.length < 3 ){ txt_nom_pereck1=false; msg = msg + "Your name should be minimun 3 char length";} if(txt_nom_pereck1){document.getElementById("submit_etape4").style.display='block'; } else{document.getElementById("submit_etape4").style.display='none'; } } window.onload = function () { var submit_etape4 = document.getElementById("submit_etape4"); var txt_nom_pere = document.getElementById("txt_nom_pere"); var txt_prenom_pere = document.getElementById("txt_prenom_pere"); var txt_courriel_pere = document.getElementById("txt_courriel_pere"); var txt_courriel_pere_conf = document.getElementById("txt_courriel_pere_conf"); var txt_nom_pereck1=false; document.getElementById("submit_etape4").style.display='none'; txt_nom_pere.onkeyup = formValidation1; txt_prenom_pere.onkeyup = formValidation1; } //************Partie 2 : ******///////////////////////////// /* function formValidation2(oEvent) { oEvent = oEvent || window.event; var txtField = oEvent.target || oEvent.srcElement; var txt_nom_pereck2=true; var msg=" "; if(document.getElementById("txt_courriel_pere").value.length < 3 ){ txt_nom_pereck2=false; msg = msg + "Your name should be minimun 3 char length";} if(document.getElementById("txt_courriel_pere_conf").value.length < 3 ){ txt_nom_pereck2=false; msg = msg + "Your name should be minimun 3 char length";} if(txt_nom_pereck2){document.getElementById("submit_etape5").style.display='block'; } else{document.getElementById("submit_etape5").style.display='none'; } } window.onload = function () { var submit_etape5 = document.getElementById("submit_etape5"); var txt_courriel_pere = document.getElementById("txt_courriel_pere"); var txt_courriel_pere_conf = document.getElementById("txt_courriel_pere_conf"); var txt_nom_pereck2=false; document.getElementById("submit_etape5").style.display='none'; txt_nom_pere.onkeyup = formValidation2; txt_prenom_pere.onkeyup = formValidation2; } Je voulais activer cette partie pour comtrole le Form 2 Le probleme existe au niveau des nom des fonctions I wanted this part to enable the Comtrol Form 2 The problem exists at the level of function names */ </script> </head> <body > <form method=" post" action="form-success.php"> <table> <tr> <td>First Name</td> <td><input type="text" id="txt_nom_pere" name="FirstName"></td> </tr> <tr> <td>First Name</td> <td><input type="text" id="txt_prenom_pere" name="FirstName"></td> </tr> </table> <input type="button" id="submit_etape4" value="Sign Up!!" style="display:none;" /> </form> <form method=" post" action="form-success.php"> <table> <tr> <td>First Name</td> <td><input type="text" id="txt_courriel_pere" name="FirstName"></td> </tr> <tr> <td>First Name</td> <td><input type="text" id="txt_courriel_pere_conf" name="FirstName"></td> </tr> </table> <input type="button" id="submit_etape5" value="Sign Up!!" style="display:none;" /> </form> </body> </html> Hey guys. This is vague because I dont know what exactly to tell you but please reply with me so I can fix this. I want to add something to my forum. Specifically, I want to add a HTML and Picture button for when you go to reply. Like posting an article here, there are also these options (font, alignment, insert image) I do not know how to achieve this but shouldnt be too hard. Here are the two sources you will need to look through to help me fix the forum. http://neoweather.com/FWFORUM.JS http://static.websimages.com/JS/fw.js THANKS Hi, I am not entirely sure what I am doing wrong here, and I have been looking at this for ages, so apologies in advance if I have become so bleary eyed I can't see something simple. I use php to create buttons based on values pulled for a table. The problem I have is when you click on the first button the javascript function works great, when you click on the next button you get the same output even though it should be different results. I am working in ff and I can see on my firebug console that the javascript function is being called, but it is not passing the new value of the second or third button, it just keeps repassing the value of the first button. So not entirely sure where I am going wrong here. My page is: Code: <script type="text/javascript"> function loadXMLDoc2(File,ID,Msg){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; } } var params=Msg; xmlhttp.open("POST",File,true); xmlhttp.setRequestHeader("Pragma", "Cache-Control:no-cache"); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(params); } </script> <head> <body> <?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); $result = mysql_query("SELECT DISTINCT theme FROM goods WHERE category='{$_POST['category']}' ORDER BY theme DESC"); while($row = mysql_fetch_array($result)){ echo '<input type="text" class="hidden" name="theme" id="theme" value="' . $row['theme'] . '" ><input type="button" class="button3" name="product" id="product" value="' . $row['product'] . '" onClick="loadXMLDoc2(\'getShow.php\',\'txtHint\',\'theme=\'+encodeURI(document.getElementById(\'rtheme\').value))" > '; } echo '<br /><br /> <div id="txtHint"><div> <br /> <br />'; mysql_close($con); ?> And getShow.php produces a table with a list of product images, names and prices, based on theme. So basically not sure where I am going wrong here? Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks hello everyone I am working on a quiz which marks the user and displays to different screens when the total has been calculated. If the user gets over 80% a congratulations page is shown but if you score less your told to go back and look at some of the material again. I would like the congratulations page to show a button to let the users continue on to the next section of the tutorial. Does any one have any ideas how I could do this? im stumped. I have inserted the code below, any help would be much appreciated as I'm a little stuck :/ Code: // Function to create arrays. function makeArray(len) { for (var i = 0; i < len; i++) this[i] = null; this.length = len; } // creates objects for this question. function makeQuestion(question, correctAnswer) { var args = makeQuestion.arguments; this.question = question; this.correctAnswer = correctAnswer; this.userAnswer = null; this.isCorrect = isCorrect; this.showForm = showForm; this.userChoices = new makeArray(args.length - 2); for (var i = 0; i < args.length - 2; i++) { this.userChoices[i] = args[i + 2]; } } // determins if the questions answered correctly function isCorrect() { if (this.correctAnswer == this.userAnswer) return true; else return false; } // Method to display contents of question object. function showForm(n) { //argument n is the number of the question. document.write((n + 1) + '. ' + this.question + '<BLOCKQUOTE><FORM>'); //n+1 = the number of the question in the array (has to add one because the array starts with 0 or the first question would be number 0, this question displays the questions text, blockquote off sets the answer making them indented. for (var i = 0; i < this.userChoices.length; i++) { //goes through the questions one by one. document.write('<INPUT TYPE = "RADIO" NAME = "q' + n + //create the radio buttons. '" onClick = "quiz[' + n + '].userAnswer = ' + i + '">'); document.write(this.userChoices[i] + '<BR>'); } document.write('</FORM></BLOCKQUOTE>'); } // This corrects the quiz, dispays the correct answers and the score. function correctQuiz() { var correct = 0; // sets the correct page to a score of zero correctPage = '<HTML><TITLE>Corrections</TITLE><BODY BGCOLOR = "#FFFFFF">'; // sets the attributes of the correction page for (var i = 0; i < quiz.length; i++) { //loop runs through questions if (quiz[i].isCorrect()) correct++; // the is correct starts at 0 every time is correct returns true (an answer is correct) it adds 1 to the number adding up correct answers. } var score = Math.round((correct / quiz.length) * 100); // find out the % of correct answers by using math and the % equation correctPage += 'Sco <STRONG>' + score + '</STRONG> %'; if (correct < (quiz.length / 100) * 80) { //if the correct number is less than the quiz length then not all the answers were correct if it is the same then all ansers were correct. correctPage += ifWrong; // if there were wrong answers for (var i = 0; i < quiz.length; i++) { // starts a for loop through the answers if (!quiz[i].isCorrect()) { // if quiz doesn't = to iscorrect. correctPage += (i + 1) + '. ' + // this shows what number was wrong. quiz[i].userChoices[quiz[i].correctAnswer] + '<BR>'; // displays the correct answes for the questions that were wrong } } } else correctPage += ifAced; // this is the correct page displayed if all the answers were right. correctPage += '</BODY></HTML>'; // opens the window of correct page correctwin = window.open ('', '', 'height=300,width=300,scrollbars=yes'); if (correctwin.opener == null) correctwin.opener = window; correctwin.location = 'javascript:opener.correctPage'; } // Message to display if quiz is aced. var ifAced = "<P>Well done! you have passed the test. You can now move on to the next section of the tutorial<P>"; // Message to display if any are wrong. var ifWrong = "<P>Check below to see the answers that you got wrong. It maybe helpful if you go back and read the bits your unsure of.<P>"; // Create seven question objects... quiz = new makeArray(8); // this is how many questions there is in the quiz quiz[0] = new makeQuestion("What is the correct name for the leg marking found in picture 1?", // 1st question starts at 0 because thats the first number in an array 2, // correct answer "Sock", // choice 0 "Stocking", // choice 1 "Coronet band", // choice 2 "half cannon"); // choice 3 quiz[1] = new makeQuestion("What is the correct name for the leg marking found in picture 2?", // 2nd question 0, // correct answer "Sock", // choice 0 "Stocking", // choice 1 "Coronet band", //choice 2 "half cannon"); //choice 3 quiz[2] = new makeQuestion("What is the correct name for the leg marking found in picture 3?", 1, // correct answer "Sock", // choice 0 "Stocking", // choice 1 "Coronet band", //choice 2 "half cannon"); quiz[3] = new makeQuestion("What is the correct name for the leg marking found in picture 4?", 3, // correct answer "Sock", // choice 0 "Stocking", // choice 1 "Coronet band", //choice 2 "half cannon"); quiz[4] = new makeQuestion("What is the correct name for the face marking found in picture 5?", 2, "Bald", "Star", "Snip", "Blaze"); quiz[5] = new makeQuestion("what is the correct name for the face marking found in picture 6?", 0, "Bald", "Star", "Snip", "Blaze"); quiz[6] = new makeQuestion("what is the correct name for the face marking found in picture 7?", 3, "Bald", "Star", "Snip", "Blaze"); quiz[7] = new makeQuestion("what is the correct name for the face marking found in picture 8?", 1, "Bald", "Star", "Snip", "Blaze"); |