JavaScript - Problem Adding To Style.opacity
Hi Guys,
Been stuck on this for too long now. I'm trying to write a function that rotates images with a fade. The function work properly, however I can't make the images fade back in. The fadein function won't add to the .style.opacity Here's the code with the php Code: function fadeout() { b<?php echo ($AF_list_artist_id->artist_id); ?>.style.opacity = (b<?php echo ($AF_list_artist_id->artist_id); ?>.style.opacity - 0.01); if(b<?php echo ($AF_list_artist_id->artist_id); ?>.style.opacity == 0.1) { clearInterval(fadeouttimer); b<?php echo ($AF_list_artist_id->artist_id); ?>.src = a<?php echo ($AF_list_artist_id->artist_id); ?>[starter<?php echo ($AF_list_artist_id->artist_id); ?>]; function fadein() { b<?php echo ($AF_list_artist_id->artist_id); ?>.style.opacity = (b<?php echo ($AF_list_artist_id->artist_id); ?>.style.opacity + 0.01); //alert(b<?php echo ($AF_list_artist_id->artist_id); ?>.style.opacity); if(b<?php echo ($AF_list_artist_id->artist_id); ?>.style.opacity == 1) { clearInterval(fadeintimer); setTimeout("rotate<?php echo ($AF_list_artist_id->artist_id); ?>("+(starter<?php echo ($AF_list_artist_id->artist_id); ?>+1)+")",6000); } } var fadeintimer = setInterval(fadein,10); } } var fadeouttimer = setInterval(fadeout,10); and without Code: function fadeout() { b7.style.opacity = (b7.style.opacity - 0.01); if(b7.style.opacity == 0.1) { clearInterval(fadeouttimer); b7.src = a7[starter7]; function fadein() { b7.style.opacity = (b7.style.opacity + 0.01); //alert(b7.style.opacity); if(b7.style.opacity == 1) { clearInterval(fadeintimer); setTimeout("rotate7("+(starter7+1)+")",6000); } } var fadeintimer = setInterval(fadein,10); } } var fadeouttimer = setInterval(fadeout,10); Similar TutorialsI have found that in IE8 I cannot give an element the alpha filter (opacity) if it has the position style set to something (relative or absolute). An element without the position style (it is the empty string) can have opacity in IE8. I have found that in IE7 I can only give an element the alpha filter if the position style is set to something (relative or absolute). An element without a position style will not take the alpha filter. This is a major conundrum. Does anyone have any insight into this bug? Given the above, I can only achieve opacity in one of the two browsers. I have both IE8 and IE7 running in standards mode. The opacity is being set programmatically with JS like so: obj.style.filter = "alpha(opacity="+opacity+")"; where opacity is an integer between 0 and 100. Obviously I don't have any problem with any other browser doing opacity because it is different styles for them and they don't care about the position style at all. Hi there. I just started out learning javascript and jQuery.. and here's one of those bump that Im unable to pass through.. So here's the problem.. I tried writing a simple modal effect on the site I was working on.. since I'm fairly new to javascript and jQuery so please bear with me The problem that I am having is that the opacity of the #dialog (the white part in the middle ) is being inherited from the #mask.. the black part that covers the page.. I tried setting the opacity to #dialog{opacity:1;} but to no avail it's not working.. I'm trying to change the opacity cause the opacity is affecting the readability of the content.. Here's the simple code that I wrote.. can you please check them up? Its been only two days since I started reading about Javascript and jQuery so please have some mercy you can check up the page here.. http://dev.crownshipping.com.ph/single_update.html just click on the boats.. and the modal thingy will pop up.. hope someone can help and enlighten me.. I'mma fast learner.. if you can give resource links.. except w3schools.. I already read the whole thing Thanks Andrew here's the html code.. Code: <div id="mask"> <div id="dialog" class="window"> <!-- close button is defined as close class --> <a href="#" class="close">Close X</a> <h1>Vessel Name - KiKi C</h1> <img src="images/single_update.jpg" alt="xxx"/> </div><!--dialog--> </div><!--mask--> here's the javascript code.. Code: <script src="js/jquery-1.2.6.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(document).ready(function(){ //select all the a tag with name equal to modal $("a.modal").click(function(e) { //Cancel the link behavior e.preventDefault(); //Get the A tag var id = $(this).attr('href'); //Get the screen height and width var maskHeight = $(document).height(); var maskWidth = $(document).width(); //Set height and width to mask to fill up the whole screen $('#mask').css({'width':maskWidth,'height':maskHeight}); //transition effect $('#mask').fadeIn(1000); $('#mask').fadeTo("slow",.8); //Get the window height and width var winH = $(window).height(); var winW = $(window).width(); //Set the popup window to center $('#dialog').css('top', winH/2-$(id).height()/2); $('#dialog').css('left', winW/2-$(id).width()/2); //transition effect $('#dialog').fadeIn(2000); $('#dialog').fadeTo("slow",1); }); //if close button is clicked $('.close').click(function (e) { //Cancel the link behavior e.preventDefault(); $('#mask, .window').fadeOut(1000); }); }); </script> I am struggeling to get this to work in both IE, Firefox and Opera. I have an ajax application that changes the tr row bgcolor if the row is clicked and thereby item is added successfully to another items-list. My problem is to determine if the bg-color has changed or not, if it has changed, do not append the ordinary bgcolor on onmouseout and do not change color if you roll mouse over the row after this is done. The following is my problem: Code: // $bgfarve is the default row color // this works in IE and Opera but not in Firefox style="background-color: $bgfarve;" onmouseout="javascript: if(this.style.backgroundColor!='#ccff66')this.style.backgroundColor='$bgfarve';" onmouseover="javascript: if(this.style.backgroundColor!='#ccff66')this.style.backgroundColor='#dddddd';" // this works in Firefox but not the others style="background-color: $bgfarve;" onmouseout="javascript: if(this.style.backgroundColor!='rgb(204, 255, 102)')this.style.backgroundColor='$bgfarve';" onmouseover="javascript: if(this.style.backgroundColor!='rgb(204, 255, 102)')this.style.backgroundColor='#dddddd';" I had one solution working by setting ordinary bg and onmouseover colors on the tbody tag, and the chart was setting tr-color - but IE was very very very slow on that. Any ideas ? Anyone ? Hey, I'm a beginner in javascript and I have a problem setting up a tag. I want to change the background color ONLY if it is #d0d0d0, so I made up these scripts: Code: <b class="nav1" id="nav1" onclick="highlightnav1()" onmouseover="overnavigation(this)" onmouseout="outnavigation(this)">Link 1</b> <b class="nav2" id="nav2" onclick="highlightnav2()" onmouseover="overnavigation(this)" onmouseout="outnavigation(this)">Link 2</b> <b class="nav3" id="nav3" onclick="highlightnav3()" onmouseover="overnavigation(this)" onmouseout="outnavigation(this)">Link 3</b> <b class="nav4" id="nav4" onclick="highlightnav4()" onmouseover="overnavigation(this)" onmouseout="outnavigation(this)">Link 4</b> <b class="nav5" id="nav5" onclick="highlightnav5()" onmouseover="overnavigation(this)" onmouseout="outnavigation(this)">Link 5</b> Code: function overnavigation(obj){ if (obj.style.backgroundColor='#d0d0d0'){ obj.style.backgroundColor='#e0e0e0'; } } function outnavigation(obj){ if (obj.style.backgroundColor='#e0e0e0'){ obj.style.backgroundColor='#d0d0d0'; } } This doesn't work, and because I don't have mush experience I don't know how to fix it. Could anybody help me? ------------ Sorry for my bad english, I'm Dutch Hi All, I have a web application which has two DIV, one is main and one is child. I am having problem in printing multiple pages. There is a lot of data in the child DIV and i am using JavaScript functions to control the print functionality. When i print using window.print(), only the data on the main page currently being showed is printed. I further researched and checked out the Style.Overflow property. Now i am using divMain.style.overflow = "visible" After this the complete print comes. But in Firefox, the scroll bar disappears and only single page is left with no scroll bar . Now if after print i give divMain.style.overflow = "Auto" OR divMain.style.overflow = "Scroll", still the scroll bar doesn't come and if it comes then its inactive. I am unable to see the complete data on the page after the print is taken. The problem is not coming in I.E and the full data with scroll bar is recovered in I.E. Please help me how to get the normal page with full data and scroll bar after printing in Firefox. I have the following HTML code: Quote: <form id="registration" action="/cgi-bin/registration.cgi" method="POST" onsubmit="return control()"> <fieldset> <legend>Fill up this module</legend> Private <input id="private" type="radio" name="type" value="private" onclick="return addPrivate()"/><br/> Community/Organization <input id="organization" type="radio" name="type" onclick="alert('Organization')"/><br/> <br/> and the following javascript code: Quote: function addPrivate() { var root = document.getElementById('registration'); var label1 = document.getElementById('label'); label1.appendChild(document.createTextNode('First Name: ')); var label2 = document.getElementById('label'); label2.appendChild(document.createTextNode('Last Name: ')); var label3 = document.getElementById('label'); label3.appendChild(document.createTextNode('Address*: ')); var label4 = document.getElementById('label'); label4.appendChild(document.createTextNode('Profession: ')); var div = document.createElement('div'); div.appendChild(label1); div.appendChild(label2); div.appendChild(label3); div.appendChild(label4); root.appendChild(div); } but div tag is not added. Where is the problem? So I have been struggling with a Javascript issues for a couple of days now and can't find an answer anywhere online that has helped. I have a javascript loop that is looping through all of my <dfn> html tags. These tags are used to show a glossary term on my page. When the user mouses over the term it shows a popup with the term name and the definition. Here is my javascript function: Code: function definitionRollover(){ var j; var dfns = document.getElementsByTagName('dfn') for (j=0; j<dfns.length;j++){ var term = dfns[j].innerHTML.charAt(0).toUpperCase() + dfns[j].innerHTML.slice(1); var definitionArray = new Array(term, dfns[j].title); dfns[j].onmouseover = function(){stm(definitionArray,Style[0])} dfns[j].onmouseout = function(){htm();}; } } As you can see I am adding a onmouseover event to these <dfn> tags which calls another function (stm) with the definition and term being held in the definitionArray. This works great until I have multiple terms on a page. When I have multiple terms it only shows the last terms definition for all terms. My question is how I can get it to work for all terms. I know that throughout the loop the definitionArray is holding the correct info at the correct time but for some reason it only shows the last one. I hope that this makes sense and if anyone could give me any tips or leads it would be very much appreciated. Hey, im having another problem with my JavaScript. I wanted to call 2 functions inline, but I can't seem to do it. So I have added the function (add_event_listeners) to the function (load_doc) that is usually called. JavaScript debugger is saying: Code: Uncaught TypeError: Cannot read property 'addEventListener' of null JavaScript: PHP Code: //Get httpobject function getHTTPObject() { var http = false; if (window.XMLHttpRequest) { http = new XMLHttpRequest(); } else if (window.ActiveXObject) { http = new ActiveXObject("Microsoft.XMLHTTP"); } return http; } //This function attaches events to elements. var addEvent = function( elm, evt, fun ) { if ( elm.addEventListener ) { elm.addEventListener( evt, fun, false ); } else if ( elm.attachEvent ) { elm.attachEvent( 'on' + evt, fun ); } else { elm [ 'on' + evt ] = fun; } }; function load_doc(doc, parent) { add_event_listeners(); document.getElementById(parent).innerHTML = "Fetching data..."; var http = getHTTPObject(); if (http != undefined) { http.onreadystatechange = function() { req_doc(doc, parent, http); }; http.open("GET", doc, true); http.send(""); } } function req_doc(doc, parent, req) { if (req.readyState == 4) {//only if req is loaded if (req.status == 200) {//And if its okay document.getElementById(parent).innerHTML = req.responseText; } else { document.getElementById(parent).innerHTML = "Error fetching data: " + req.status + "\n" + req.statusText; } } } //Script used to hide elements. Usage: expand(element id) function expand(elm) { var ex = document.getElementById(elm).style.display; if (ex == "none") { var obj = document.getElementById(elm); obj.style.display = "inline"; } else if (ex == "inline") { var obj = document.getElementById(elm); obj.style.display = "none"; } } function add_event_listeners() { addEvent(document.getElementById('username'), "click", check_database); addEvent(document.getElementById('email'), "click", check_database); addEvent(document.getElementById('password_2'), "blur", check_password); } var check_database = function() { check_database_existing(this); }; var check_password = function() { compare_fields(this); }; function check_database_existing(obj) { } function compare_fields(obj) { var field2 = obj.id.split("_"); field2 = document.getElementById(field2[0]).value; if (obj.value == field2) { if (obj.value.length >= 4) { document.getElementById("pass_status").style.color = "#00CC00"; document.getElementById("pass_status").innerHTML = "OK!"; } else { document.getElementById("pass_status").innerHTML = "Please must be between 5 - 14 characters long! "; document.getElementById("pass_status").style.color = "#FF0000"; } } else { document.getElementById("pass_status").innerHTML = "Passwords do not match!"; document.getElementById("pass_status").style.color = "#FF0000"; } } HTML: Code: <div style="border-color:#090; border-width:1px; border-style:solid;"> <div class="login_button register_button" onClick="load_doc('pages/forms/login_form.php', 'login_form')">Back to login</div> <h1>Register</h1> <h3>DrawSomething - WordGuesser</h3> <br /> <form id="register" action="php/register.php" method="post"> Username<br /><h4 id="username_status">(waiting)</h4><br /><input type="text" name="username" id="username" class="text login_field"><br /> Email<br /><h4 id="email_status">(waiting)</h4><br /><input type="email" name="email" id="email" class="text login_field"><br /> --<br /> Password<br /><input type="password" name="password" id="password" class="text login_field"><br /> Retype<br /><h4 id="pass_status">(waiting)</h4><br /><input type="r_password" id="password2" name="password" class="text login_field"> <br /> <input type="submit" value="Register" class="button green" /> </form> </div> Hi, I have this design, where the menu is a JavaScript that makes the content page flow in from the right. As a standard there are only 4 menu objects, but I need a fifth one. I have tried to add another myself, and change everything i thought important in the javascript.js, but it just doesn't work. The javascript screws up, so I am clearly missing something. Therefore i'm hoping that someone inhere, can help me adding it. Below are the index, javascript and stylesheet included. If I'm not making myself clear, please let me know and I will try to explain it better Thanks walkie index.htm 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>Identity</title> <script type="text/javascript" src="javascript/jquery.js"></script> <script type="text/javascript" src="fancybox/jquery.fancybox.js"></script> <script type="text/javascript" src="javascript/javascript.js"></script> <link rel="stylesheet" type="text/css" href="css/style.css" /> <link rel="stylesheet" href="fancybox/jquery.fancybox.css" type="text/css" media="screen" /> </head> <body> <div id="leftSide"> <!--Site Title--> <div id="title"> <!--Main Title--> <h1><span></span>Identity</h1> <!--Caption/Sub Title--> <span class="titleSubText">the portfolio of john smith</span> </div> <div id="arrowWrapper"><div id="arrow"></div></div> <div id="buttonsWrapper"> <!--About Button--> <div id="aboutButtonWrapper"> <div class="navButton" id="aboutButton"></div> <div class="navCaption" id="aboutCaption"> <!--About Button: Label--> <span class="navCaptionText">about</span><br /> <!--About Button: Sub-Label--> <span class="navSubCaptionText">who I am</span> </div> </div> <!--Portfolio Button--> <div id="portfolioButtonWrapper"> <div class="navButton" id="portfolioButton"></div> <div class="navCaption" id="portfolioCaption"> <!--Portfolio Button: Label--> <span class="navCaptionText">portfolio</span><br /> <!--Portfolio Button: Sub-Label--> <span class="navSubCaptionText">my work</span> </div> </div> <!--Services Button--> <div id="servicesButtonWrapper"> <div class="navButton" id="servicesButton"></div> <div class="navCaption" id="servicesCaption"> <!--Services Button: Label--> <span class="navCaptionText">services</span><br /> <!--Services Button: Sub-Label--> <span class="navSubCaptionText">what I do</span> </div> </div> <!--Contact Button--> <div id="contactButtonWrapper"> <div class="navButton" id="contactButton"></div> <div class="navCaption" id="contactCaption"> <!--Contact Button: Label--> <span class="navCaptionText">contact</span><br /> <!--Contact Button: Sub-Label--> <span class="navSubCaptionText">get in touch</span> </div> </div> </div> </div> <div id="contentPanelWrapper"> <div id="contentPanelEdge"></div> <!--Wrapper That Contains 'About' Content--> <div class="content" id="aboutContent"> <!--Title--> <div class="contentTitle">about</div> <!--Body Text--> <div id="aboutText"> <h3>Who I Am</h3><br /> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius, nisi non pretium elementum, dolor leo sagittis nunc, at pharetra ligula urna ut ligula. Morbi ac erat ante, in feugiat libero. Quisque nec mauris neque. Quisque sit amet condimentum turpis. Sed at arcu eu augue venenatis viverra. Vivamus odio nulla, facilisis et commodo at, sagittis id neque.</p><br /> <p>Nulla facilisi. Quisque non tellus justo, at tempor nisl. Fusce eleifend augue euismod sem varius pulvinar. Etiam rutrum magna in quam ultrices sit amet dictum nulla commodo.</p> </div> </div> <!--Wrapper That Contains 'Portfolio' Content--> <div class="content" id="portfolioContent"> <!--Title--> <div class="contentTitle">portfolio</div> <!--Image Slider--> <div id="portfolioSlider"> <div id="sliderToolbar"> <div class="sliderButton" id="prevButton"></div> <div class="sliderButton" id="nextButton"></div> </div> <div id="imageWrapper"> <ul id="imgList"> <!--Portfolio Images Go Here (See Documentation)--> <li><a class="sliderImage" href="images/portfolio/img1-large.jpg"><img alt="" src="images/portfolio/img1-small.jpg" /></a></li> <li><a class="sliderImage" href="images/portfolio/img2-large.jpg"><img alt="" src="images/portfolio/img2-small.jpg" /></a></li> <li><a class="sliderImage" href="images/portfolio/img3-large.jpg"><img alt="" src="images/portfolio/img3-small.jpg" /></a></li> <li><a class="sliderImage" href="images/portfolio/img4-large.jpg"><img alt="" src="images/portfolio/img4-small.jpg" /></a></li> </ul> </div> </div> </div> <!--Wrapper That Contains 'Services' Content--> <div class="content" id="servicesContent"> <!--Title--> <div class="contentTitle">services</div> <!--Service 1 Column--> <div class="serviceColumn" id="serviceColumn1"> <h3>Identity Design</h3><br /> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius, nisi non pretium elementum, dolor leo sagittis nunc, at pharetra ligula urna ut ligula.</p> </div> <!--Service 2 Column--> <div class="serviceColumn" id="serviceColumn2"> <h3>Web Design</h3><br /> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius, nisi non pretium elementum, dolor leo sagittis nunc, at pharetra ligula urna ut ligula.</p> </div> <!--Service 3 Column--> <div class="serviceColumn" id="serviceColumn3"> <h3>Icon + UI Design</h3><br /> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec varius, nisi non pretium elementum, dolor leo sagittis nunc, at pharetra ligula urna ut ligula.</p> </div> </div> <!--Wrapper That Contains 'Contact' Content--> <div class="content" id="contactContent"> <!--Title--> <div class="contentTitle">contact</div> <div id="contactFormWrapper"> <!--Contact Form--> <form id="contact" method="post" action="mail.php"> <input type="text" id="name" name="name" value="name" /> <input type="text" id="email" name="email" value="email" /><br /><br /> <textarea id="message" name="message" rows="" cols="">message</textarea> <input type="image" id="submit" src="images/sendButtonDis.png" disabled="disabled" /> </form> <div id="successMessage"></div> </div> </div> </div> </body> </html> javascript.js Code: numImages=0; currentImage=1; currentPanel="none"; $(document).ready(function(){ // Initializes FancyBox Lightbox $("a.sliderImage").fancybox({ 'zoomSpeedIn':200, 'zoomSpeedOut':200, 'overlayShow':true, 'padding':4 }); SelectButton("none"); $("#arrow").fadeOut(0); if (navigator.appVersion.indexOf("MSIE 7.0")!=-1){ $("input").css({"height":13}); $("#name").css({"width":155}); }; $("#title").click(function(){ ShowPanel("none"); }); // Handles Formatting the Portfolio Slider $("#imgList").children().each(function(){ numImages++; }); $("#imageWrapper").css({"width":(numImages*541)}); // Handles Function of the Portfolio Slider $("#prevButton").click(function(){ if (currentImage==1){ currentImage=numImages; } else { currentImage--; }; $("#imageWrapper").animate({"left":-((currentImage-1)*541)},500); }); $("#nextButton").click(function(){ if (currentImage==numImages){ currentImage=1; } else { currentImage++; }; $("#imageWrapper").animate({"left":-((currentImage-1)*541)},500); }); // Handles Rollover and Click For the Nav Buttons $("#aboutButton").mouseenter(function(){ SelectButton("about"); }); $("#portfolioButton").mouseenter(function(){ SelectButton("portfolio"); }); $("#servicesButton").mouseenter(function(){ SelectButton("services"); }); $("#contactButton").mouseenter(function(){ SelectButton("contact"); }); $("#aboutButton,#portfolioButton,#servicesButton,#contactButton").mouseleave(function(){ SelectButton("none"); }); $("#aboutButton").click(function(){ ShowPanel("about"); }); $("#portfolioButton").click(function(){ ShowPanel("portfolio"); }); $("#servicesButton").click(function(){ ShowPanel("services"); }); $("#contactButton").click(function(){ ShowPanel("contact"); }); // Handles Contact Form Behavior $("#name").focus(function(){ $("#name").css({"background-color":"#FFFFFF"}); if ($("#name").val()=="name"){ $("#name").val(""); $("#name").css({"color":"#444444"}); }; }); $("#name").blur(function(){ if ($("#name").val()==""){ $("#name").val("name"); $("#name").css({"color":"#888888"}); $("#name").css({"background-color":"#ffdddd"}); }; }); $("#email").focus(function(){ $("#email").css({"background-color":"#FFFFFF"}); if ($("#email").val()=="email"){ $("#email").val(""); $("#email").css({"color":"#444444"}); }; }); $("#email").blur(function(){ if ($("#email").val()==""){ $("#email").val("email"); $("#email").css({"color":"#888888"}); $("#email").css({"background-color":"#ffdddd"}); }; if ($("#email").val().indexOf("@")==-1 || $("#email").val().indexOf(".")==-1){ $("#email").css({"background-color":"#ffdddd"}); }; }); $("#message").focus(function(){ $("#message").css({"background-color":"#FFFFFF"}); if ($("#message").val()=="message"){ $("#message").val(""); $("#message").css({"color":"#444444"}); }; }); $("#message").blur(function(){ if ($("#message").val()==""){ $("#message").val("message"); $("#message").css({"color":"#888888"}); $("#message").css({"background-color":"#ffdddd"}); }; }); $("#submit").mousedown(function(){ $("#submit").attr({"src":"images/sendButtonSel.png"}); }); $("#submit").mouseup(function(){ $("#submit").attr({"src":"images/sendButton.png"}); }); $("#submit").mouseout(function(){ $("#submit").attr({"src":"images/sendButton.png"}); }); $("#name,#email,#message").keyup(function(){ if ($("#name").val()!="" && $("#name").val()!="name" && $("#email").val()!="" && $("#email").val()!="email" && $("#email").val().indexOf("@")>-1 && $("#email").val().indexOf(".")>-1 && $("#message").val()!="" && $("#message").val()!="message"){ EnableSubmitButton(); } else { DisableSubmitButton(); }; }); $("#submit").click(function(){ DisableSubmitButton(); var dataString="name=" + $("#name").val() + "&email=" + $("#email").val() + "&message=" + $("#message").val(); $.ajax({ type: "POST", url: "mail.php", data: dataString, success: function() { ResetForm(); $("#successMessage").fadeIn(10); setTimeout('$("#successMessage").fadeOut(1000);',2000); } }); return false; }); }); function EnableSubmitButton(){ $("#submit").attr({"disabled":""}); $("#submit").attr({"src":"images/sendButton.png"}); }; function DisableSubmitButton(){ $("#submit").attr({"disabled":"disabled"}); $("#submit").attr({"src":"images/sendButtonDis.png"}); }; function ResetForm(){ DisableSubmitButton(); $("#name, #email, #message").css({"background-color":"#FFFFFF"}); $("#name, #email, #message").css({"color":"#888888"}); $("#name").val("name"); $("#email").val("email"); $("#message").val("message"); }; function ShowPanel(panel){ currentPanel=panel; SelectButton(panel); $(".content").fadeOut(250); switch(panel){ case "none": $("#contentPanelWrapper").animate({"left":"100%"},500); $("#arrow").fadeOut(50) break; case "about": $("#contentPanelWrapper").animate({"left":"100%"},500,function(){ $("#aboutContent").show(); $("#contentPanelWrapper").animate({"left":"44%"},500); }); $("#arrow").animate({"top":22},150,function(){$("#arrow").fadeIn(50)}); break; case "portfolio": $("#contentPanelWrapper").animate({"left":"100%"},500,function(){ $("#portfolioContent").show(); $("#contentPanelWrapper").animate({"left":"44%"},500); }); $("#arrow").animate({"top":98},150,function(){$("#arrow").fadeIn(50)}); break; case "services": $("#contentPanelWrapper").animate({"left":"100%"},500,function(){ $("#servicesContent").show(); $("#contentPanelWrapper").animate({"left":"44%"},500); }); $("#arrow").animate({"top":170},150,function(){$("#arrow").fadeIn(50)}); break; case "contact": $("#contentPanelWrapper").animate({"left":"100%"},500,function(){ $("#contactContent").show(); $("#contentPanelWrapper").animate({"left":"44%"},500); }); $("#arrow").animate({"top":243},150,function(){$("#arrow").fadeIn(50)}); break; }; }; function SelectButton(button){ if (currentPanel!="about"){ $("#aboutCaption").animate({"left":50},{queue:false, duration:250}); $("#aboutCaption").animate({"opacity":0},{queue:false, duration:250}); $("#aboutButton").css({"background-position":"0px 0px"}); }; if (currentPanel!="portfolio"){ $("#portfolioCaption").animate({"left":50},{queue:false, duration:250}); $("#portfolioCaption").animate({"opacity":0},{queue:false, duration:250}); $("#portfolioButton").css({"background-position":"0px -64px"}); }; if (currentPanel!="services"){ $("#servicesCaption").animate({"left":50},{queue:false, duration:250}); $("#servicesCaption").animate({"opacity":0},{queue:false, duration:250}); $("#servicesButton").css({"background-position":"0px -128px"}); }; if (currentPanel!="contact"){ $("#contactCaption").animate({"left":50},{queue:false, duration:250}); $("#contactCaption").animate({"opacity":0},{queue:false, duration:250}); $("#contactButton").css({"background-position":"0px -192px"}); }; switch(button){ case "none": break; case "about": $("#aboutCaption").animate({"left":70},{queue:false, duration:250}); $("#aboutCaption").animate({"opacity":1},{queue:false, duration:250}); $("#aboutButton").css({"background-position":"65px 0px"}); break; case "portfolio": $("#portfolioCaption").animate({"left":70},{queue:false, duration:250}); $("#portfolioCaption").animate({"opacity":1},{queue:false, duration:250}); $("#portfolioButton").css({"background-position":"65px -64px"}); break; case "services": $("#servicesCaption").animate({"left":70},{queue:false, duration:250}); $("#servicesCaption").animate({"opacity":1},{queue:false, duration:250}); $("#servicesButton").css({"background-position":"65px -128px"}); break; case "contact": $("#contactCaption").animate({"left":70},{queue:false, duration:250}); $("#contactCaption").animate({"opacity":1},{queue:false, duration:250}); $("#contactButton").css({"background-position":"65px -192px"}); break; }; }; Hi. I'm trying to get my script below working. I've managed to get it to add fields dynamically but the remove function isn't right... and I can't think of a way round it. any ideas? also.. how can i incorporate a way for a limit on the number of fields that can be added? cheers! any help would be very appreciated. Code: <script type="text/javascript"> function addInput() { var x = document.getElementById("inputs"); x.innerHTML += "<input type=\"text\" />"; } function removeInput() { var x = document.getElementById("inputs"); x.innerHTML -= "<input type=\"text\" />"; } </script> <input type="button" value="add field" onclick="addInput();" /> <input type="button" value="remove field" onclick="removeInput();" /> <div id="inputs"></div> .. update: ah, i've just looked into the operators in more details and -= is just for numbers... so this won't work. i presume this is going to be the wrong method then. Below is the script and form fields I am working with. What I want to do is sum the two textbox fields and have the result show in the total textbox. The code works fine and the total textbox is updated with the value of form1.basic. The problem occurs when I add the "+ parseInt(document.form2.supporter.value)" code in the script section. What am I doing wrong? Thank you for your time and help. Code: <script type="text/javascript"><!-- function updatesum() { document.frmtotal.total.value = parseInt(document.form1.basic.value) + parseInt(document.form2.supporter.value)} //--></script> <tr> <td width="111"><form id="form1" name="form1" method="post" action=""> <label for="basic">$</label> <input name="basic" type="text" id="basic" size="7" maxlength="7" onchange="updatesum(this.form)" /> </form></td> </tr> <tr> <td><form id="form2" name="supporter" method="post" action=""> <label for="supporter">$</label> <input name="supporter" type="text" id="supporter" size="7" maxlength="7" onchange="updatesum(this.form)" /> </form> Hi, firstly I apologise if the title of this thread isn't quite accurate. I'm sure you've all heard it before but I am a complete newbie to Javascript so again: apologies if this is boring and tiresome to even read, let alone help with! I have been asked to make some changes to a form that uses Javascript for the form validation. There is a 'function' that contains the variables of the various form fields and then further code to raise 'alerts' if one of the fields on the form hasn't been filled in. My problem is that for some reason I am unable to add an extra variable to this code after the field of 'County' (this will hopefully make sense when you see the code / link...) and I am stumped as to why. I am able to add variables for all of the other required fields except for 'Postcode' after 'County'. This is the case for both forms. The link is he http://samdelara.co.uk/previews/banq...ation-form.htm and the code I am trying edit is below: function checkAvailibility() { // re-calculate... calculate (); if ( isName() && isAddress1() && isTown() && isCounty() && isPostcode() && isYourEmail() && isFuncDate() && somethingToQuoteFor() && isYourEmailValid() ) { document.ordersummary.emailQuote.value = "No"; setValue(); return true; } else { return false; } } function isName() { if (document.ordersummary.Name.value=="") { alert ("\n Please Enter Your Name") document.ordersummary.Name.focus(); return false; } return true; } function isAddress1() { if (document.ordersummary.Address1.value=="") { alert ("\n Please Enter Your Address") document.ordersummary.Address1.focus(); return false; } return true; } function isTown() { if (document.ordersummary.Town.value=="") { alert ("\n Please Enter Your Town") document.ordersummary.Town.focus(); return false; } return true; } function isCounty() { if (document.ordersummary.County.value=="") { alert ("\n Please Enter Your County") document.ordersummary.County.focus(); return false; } return true; } function isPostcode() { if (document.ordersummary.Postcode.value=="") { alert ("\n Please Enter Your Postcode") document.ordersummary.Postcode.focus(); return false; } return true; } function isYourEmail() { if (document.ordersummary.YourEmail.value=="") { alert ("\n Please Enter Your Email") document.ordersummary.YourEmail.focus(); return false; } return true; } function isFuncDate() { if (document.ordersummary.FuncDate.value=="") { alert ("\n Please Enter Your Function Date") document.ordersummary.FuncDate.focus(); return false; } return true; } function isemailonly() { if (document.ordersummary.emailonly.value=="") { alert ("\n Please Enter Your Email Address") document.ordersummary.emailonly.focus(); return false; } return true; } Any help with this would be very much appreciated and once again, I apologise for my distinct lack of knowledge in this area! Sam if I have an html page that uses the <style> or a <link> to call a style sheet these properties aren't available to JavaScript is there a good way to access them? eg Code: <html> <head> <title>expandable text area</title> <style type="text/css"> #expandable{ height: 100px; } </style> </head> <body> <form> <textarea id="expandable" cols="30" rows="10"></textarea> </form> </body> <script type="text/javascript"> document.getElementById('expandable').addEventListener('click',function(){ if(!this.style.height){ this.style.height = this.scrollHeight+'px'; } alert(this.style.height); }, true); </script> </html> In this example I have the height set but I cannot access it since it is not declared in the style attribute of the html element I have the following javascript function: [ function addNewWindowEvent(evType, fn) { if (window.addEventListener) { this.addEventListener("load", fn, false); return true; } else if (window.attachEvent) { var onload = "onload" this.attachEvent(onload, fn); return true; } else { return false; } } ] which is giving me a an exception every time a page on our site loads. The actual exception in firefox is this: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: https://cms-dev.stchas.edu/global/js/hdvscripts.js :: addNewWindowEvent :: line 5" data: no] and I'm not sure exactly what it's complaining about. I'm relatively new to javascript so diagnosing and fixing this problem has me quite puzzled, and so far I have been unable to find anything helpful when I try and google for information on this. I would appreciate any help or suggestions. Thanks. henryv Hello. I know I get set opacity for IE using the CSS Code: filter:alpha(opacity=50); and I set it with JS as Code: theObj.style.filter = "alpha(opacity=" + (opac * 100) + ")"; but how can I read it's initial value (and store it in a variable)? Andy. Added: I should mention I use this function to get the current style: Code: var GetStyle = function (el, strRule) { // e.g. "font-size" - robertnyman.com var elem = (typeof el === 'string') ? document.getElementById(el) : el; if (document.defaultView && document.defaultView.getComputedStyle ) { return document.defaultView.getComputedStyle(elem, '').getPropertyValue(strRule); } else if ( elem.currentStyle ) { strRule = strRule.replace(/\-(\w)/g, function (strMatch, p1) { return p1.toUpperCase(); }); return elem.currentStyle[strRule]; } else return ''; } ; Ok so I have two images class1 & class2 which both have opacity:0.3; and filter:alpha(opacity=30); added with css. I am trying to get it so when I click on class1 it will either fade in (ideally) or display as 100% opacity. I do not want both class's to be able to be 100% so if one is clicked the other would be 30%. I also have multiple instances of class1 and class2. If anyone can help me I will praise you on the highest mountain! Thanks, B Hey all, I am very new to javascript. I have been using this stacks menu I am sure you may have seen elsewhe http://net.tutsplus.com/tutorials/ja...ck-navigation/ I have modified it a bit though as I will want to use my own graphics and change a little bit how it works. I managed to make it so that the images become transparent when the stack is put back in place and then non transparent when they come back out. The problem I have is that I need the images to be transparent initially when they are in the stack. You can see the problem he http://bit.ly/cdelJu Here is the javascript for this: Code: $(function () { // Stack initialize var openspeed = 300; var closespeed = 300; $('.stack2>img').toggle(function(){ var vertical = 0; var horizontal = 90; var $el=$(this); $el.next().children().each(function(){ $(this).animate({top: vertical + 'px', left: horizontal + 'px', opacity: '10'}, openspeed); vertical = vertical + 40; horizontal = (horizontal+.75)*1.15; }); $el.next().animate({top: '40px', left: '10px'}, openspeed).addClass('openStack') .find('li a>img').animate({width: '50px', marginLeft: '9px'}, openspeed); $el.animate({paddingBottom: '0'}); }, function(){ //reverse above var $el=$(this); $el.next().removeClass('openStack').children('li').animate({top: '-33px', left: '-10px', opacity: '0'}, closespeed); $el.next().find('li a>img').animate({width: '79px', marginLeft: '0'}, closespeed); $el.animate({paddingBottom: '35px'}); }); // Stacks additional animation $('.stack2 li a').hover(function(){ $("img",this).animate({width: '56px'}, 100); $("span",this).animate({marginRight: '30px'}); },function(){ $("img",this).animate({width: '50px'}, 100); $("span",this).animate({marginRight: '0'}); }); }); and here is the css: Code: /* ================ STACK #2 ================ */ .stack2 { position: fixed; top: 28px; left: 90px;} .stack2 > img { position: relative; cursor: pointer; padding-bottom: 35px; z-index: 2; } .stack2 ul { list-style: none; position: absolute; top: 7px; cursor: pointer; z-index: 1; } .stack2 ul li { position: absolute; } .stack2 ul li img { border: 0; } .stack2 ul li span { display: none; } .stack2 .openStack li span { font-family: "Lucida Grande", Lucida, Verdana, sans-serif; display:block; height: 14px; position:absolute; top: 17px; right:60px; line-height: 14px; border: 0; background-color:#000; padding: 3px 10px; border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; color: #fcfcfc; text-align: center; text-shadow: #000 1px 1px 1px; opacity: .85; filter: alpha(opacity = 85); } #dock { top: 0; left: 100px; } a.dock-item { position: relative; float: left; margin-right: 10px; } .dock-item span { display: block; } .stack { top: 0; } .stack ul li { position: relative; } /* IE Fixes */ .stack2 { _position: absolute; } .stack2 ul { _z-index:-1; _top:-15px; } .stack2 ul li { *right:5px; } annd the html: Code: <div class="stack2"> <img src="images/stacks/stack-down.png" alt="stack"/> <ul id="stack2"> <li><a href=""><span>Aperture</span><img src="images/stacks/aperture.png" alt="Aperature" /></a></li> <li><a href="#"><span>All Examples</span><img src="images/stacks/photoshop.png" alt="Photoshop" /></a></li> <li><a href="example3.html"><span>Example 3</span><img src="images/stacks/safari.png" alt="Safari" /></a></li> <li><a href="example2.html"><span>Example 2</span><img src="images/stacks/coda.png" alt="Coda" /></a></li> <li><a href="index.html"><span>Example 1</span><img src="images/stacks/finder.png" alt="Finder" /></a></li> </ul> </div> Any help is greatly appreciated! Hello! I'm just starting to learn JavaScript, so don't take me too serious. I would like to set opacity of some element to 0 through JavaScript, using GetElementById function. This is my short code inside body of HTML: Code: <script> document.getElementById("element").style.opacity="0"; </script> <div id="element"> noopacity </div> It doesn't seem to work, what am I doing wrong? Thanks. Hey, I have a script that needs to see the current opacity value of divs but I can not find the code to make it work in IE. I've googled it for over an hour with no answer. Any suggestions? For non-IE browsers, here is the code I am using Code: div_opac = document.getElementById(some_div).style.opacity; Thanks for the help! Hey all, I found this code but don't fully understand it. Can anyone take a brief moment to explain what is occuring in the clearMenu, setOpacity and fadeMenu functions: Code: // configuration variables var timeout = 250; // milliseconds var fadeSpeed = 500; // milliseconds var useFade = true; // timers array var timers = new Array(); // state array -- by id, value = active, false = inactive var state = new Array(); // lastOpacity: used to prevent multiple timers from making the fade flicker var lastOpacity = new Array(); // MSIE has its own way of setting opacity, so we have to detect it // all the other major browsers support the standard DOM opacity property var msie = false; if( navigator.appName == "Microsoft Internet Explorer" ) msie = true; // entry point: set element to visible and clear its timers function setMenu( id ) { var e = document.getElementById(id); //When the user rolls over one of horizontal menu items, the setMenu method is called and we pass in as an argument, the id of the associated ul element, which we then set its visibility attribute to visible. e.style.visibility = "visible"; state[id] = true; setOpacity( id, 1 ); if(timers[id]) { clearTimeout(timers[id]); timers[id] = undefined; } } // set element to hidden and reset its opacity // typically called by a timer // may be used as an entry point to bypass timers and fades function hideMenu( id ) { var e = document.getElementById(id); state[id] = false; e.style.visibility = "hidden"; if(useFade) setOpacity( id, 1 ); } // entry point: hide the menu using fade (if enabled) function clearMenu( id ) { if(useFade) timers[id] = setTimeout( 'fadeMenu( "' + id + '" )', timeout ); else timers[id] = setTimeout( 'hideMenu( "' + id + '" )', timeout ); } // set the opacity // special support for MSIE function setOpacity( id, value ) { var e = document.getElementById(id); if(state[id]) value = 1; // menu fade was interrupted else if(lastOpacity[id] && (lastOpacity[id] < value)) value = lastOpacity[id]; // prevents flicker if multiple timers set if(msie) e.style.filter = 'alpha(opacity=' + value * 100 + ')'; // MS Internet Explorer else e.style.opacity = (value); // Everyone else (standard DOM) if( value == 0 ) hideMenu( id ); // when all faded, reset the menu state lastOpacity[id] = value; } // fade a menu // typically called by a timer function fadeMenu ( id ) { var start = 0; var end = 0; var s = Math.round( fadeSpeed / 25 ); // fade in 25ms increments var timer = 0; var i; state[id] = false; for( i = s; i >= 0 ; i-- ) { setTimeout( "setOpacity('" + id + "'," + ( i / s ) + ")", timer++ * fadeSpeed / s ) } } Thanks for any response. |