JavaScript - Can't Figure Out Why Getelementbyid Script Isn't Working
I'm a newbie, so it may be obvious. But can someone help me here? I want to display images based on times
Code: <script type="text/javascript"> /*<![[CDATA */ var time = new Date(); var dayNight = time.getHours(); // gets the time of the day in hours function displayImage() { if (dayNight >= 9 && dayNight <= 14) { document.getElementById("highlights").src="http://www.kacvtv.org/rotatorpics/amergrad.jpg"; } if (dayNight >= 14 && dayNight <= 17) { document.getElementById("highlights").src="http://www.kacvtv.org/rotatorpics/video-contest.jpg"; } if (dayNight >= 17 && dayNight <= 22 ) { document.getElementById("highlights").src="http://www.kacvtv.org/rotatorpics/vine.jpg"; } else { document.getElementById("highlights").src"http://www.kacvtv.org/rotatorpics/amergrad.jpg"; } } /*]]>*/ </script> Then the code in the body Code: <body onload="displayImage"> <div id="highlights"> </div> Here's a link. http://tinyurl.com/7bzkdk7 Similar TutorialsI have some simple javascript code that works fine in chrome and safari, but not Ie8 Code: <head><script type="text/javascript"> function val2() { //var num = Number(document.getElementById('PdRows').value) alert (document.getElementById('PdRows').value) } </script></head> <form action="" method="post"> <select name="PD" id="PdRows" onchange="val2()"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </form> Why? And how do I correct? http://johnathany.com/contact.html What I'm trying to do is get the googlemaps iframe to change if i hit to corresponding 3 links at the bottom. So I tried to use getElementById(leftcolumn).innerhtml to change the entire content of the div but it isnt working. Please advise. Or would there be a simpler solution like creating 3 hidden divs and just do display:block; to display them? why is getElementById not working?? pls try it and tell me if you get a hit on document.getElementById("t1"); thanks Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Tester code</title> <script type="text/javascript"> console.log("sfsg"); var e = document.getElementById("t1"); var c = e.firstChild; console.log(c); </script> </head> <body> <table> <tr> <td id="t1"><img id="img1" src="SharkSq1.png">3</td> </tr> </table> </body> </html> Hi. I'm making a web site...And the following bit of code doesn't work...It sais "document.getElementById(...) is null or not an object"...I tried various combinations of getElementById and getElementsByName but nothing works...Any help is very much appreciated. Thanks. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Rudolf-site management</title> <script language="javascript"> <!-- function Val_imag(){ if(document.site.Imagini[0].checked){ for(var i=0; i<16; i++){ document.getElementById('Fs_img')[i].style.display='none' document.getElementById('Txt_img')[i].style.display='none'}} else{ if(document.site.Imagini[1].checked){ for(var i=0; i<16; i++){ document.getElementById('Txt_img')[i].style.display='none'} document.getElementById('Fs_img0').style.display=''} else{ if(document.site.Imagini[2].checked){ for(var i=0; i<16; i++){ document.getElementById('Fs_img')[i].style.display='none'} document.getElementById('Txt_img0').style.display=''} else{ for(var i=0; i<16; i++){ document.getElementById('Fs_img')[i].style.display='none' document.getElementById('Txt_img')[i].style.display='none'}}}}} function Cont_pag3(){ if(document.site.Imagini[0].checked){ document.site.pag3_5.disabled=false} else{ if(document.site.Imagini[1].checked){ if(document.site.Fis_img[0].value!=""){ document.site.pag3_5.disabled=false} else{ document.site.pag3_5.disabled=true}} else{ if(document.site.Imagini[2].checked){ if(document.site.Text_img[0].value.length>7){ document.site.pag3_5.disabled=false} else{ document.site.pag3_5.disabled=true}}}}} // --> </script> </head> <body bgcolor=#000437> <font color=#FDB91A> <form method="post" name="site" action="site.php" enctype="multipart/form-data"> <div id="pagina3" class="comanda"> Pasul III: Imagini<br/> Pentru a trimite imaginile care vor aparea pe site (daca exista), aveti 2 optiuni: sa ne trimiteti un fisier .zip, .rar, etc sau sa scrieti un link unde le vom putea gasi.<br/><br/> Le puteti organiza cum doriti dumneavostra, dar este preferabil sa folositi una dintre variantele urmatoa <br/><br/> (folder) pagina 1: (folder) pagina 1-1: imaginile care apar pe pagina 1-1<br/> <table style="color=#FDB91A"><tr><td width="155"></td><td width="250">imaginile care apar pe pagina 1 etc</td></tr></table><br/><br/> (folder) pagina 1: imaginile care apar pe pagina 1<br/> (folder) pagina 1-1: imaginile care apar pe pagina 1-1 etc<br/><br/> (folder - nu este necesar) site: toate imaginile care apar pe site<br/> <table style="color=#FDB91A"><tr><td width="200"></td><td width="250">fisier text (.txt, .doc, .docx etc) cu numele imaginilor si pagina pe care apar</td></tr></table><br/><br/> La toate exemplele, in loc de pagina 1 etc puteti scrie numele paginii.<br/> Puteti adauga pana la 10 fisiere si pana la 15 link-uri. Pentru a adauga inca un fisier/link apasati pe butonul corespunzator.<br/> Va rugam ca fisierele trimise sa fie de maximum 5 MB. (Puteti downloada si instala gratuit <a href="http://www.rarlab.com/download.htm" target="_blank">WinRar</a> si sa-l folositi pentru a face o arhiva impartita in mai multe bucati.)<br/><br/> <input type="radio" name="Imagini" value="NuAm" onClick="Val_imag();Cont_pag3()">Site-ul nu are imagini<br/> <input type="radio" name="Imagini" value="Fisier" onClick="Val_imag();Cont_pag3()">Trimite fisier<br/> <table id="Fs_img0" style="display: none"><tr><td><input type="file" name="Fis_img" size="100" onChange="Cont_pag3()"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img1').style.display=''"></td></tr></table> <table id="Fs_img1" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img2').style.display=''"></td></tr></table> <table id="Fs_img2" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img3').style.display=''"></td></tr></table> <table id="Fs_img3" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img4').style.display=''"></td></tr></table> <table id="Fs_img4" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img5').style.display=''"></td></tr></table> <table id="Fs_img5" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img6').style.display=''"></td></tr></table> <table id="Fs_img6" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img7').style.display=''"></td></tr></table> <table id="Fs_img7" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img8').style.display=''"></td></tr></table> <table id="Fs_img8" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img9').style.display=''"></td></tr></table> <table id="Fs_img9" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img10').style.display=''"></td></tr></table> <table id="Fs_img10" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img11').style.display=''"></td></tr></table> <table id="Fs_img11" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img12').style.display=''"></td></tr></table> <table id="Fs_img12" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img13').style.display=''"></td></tr></table> <table id="Fs_img13" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img14').style.display=''"></td></tr></table> <table id="Fs_img14" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td><td width="30"></td><td><input type="button" name="Add_img_fis" value="Adauga fisier" onClick="document.getElementById('Fs_img15').style.display=''"></td></tr></table> <table id="Fs_img15" style="display: none"><tr><td><input type="file" name="Fis_img" size="100"></td></tr></table> <input type="radio" name="Imagini" value="Text" onClick="Val_imag();Cont_pag3()">Scrie/copiaza link-ul<br/> <table id="Txt_img0" style="display: none"><tr><td><input type="text" name="Text_img" size="80" onKeyUp="Cont_pag3()"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img1').style.display=''"></td></tr></table> <table id="Txt_img1" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img2').style.display=''"></td></tr></table> <table id="Txt_img2" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img3').style.display=''"></td></tr></table> <table id="Txt_img3" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img4').style.display=''"></td></tr></table> <table id="Txt_img4" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img5').style.display=''"></td></tr></table> <table id="Txt_img5" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img6').style.display=''"></td></tr></table> <table id="Txt_img6" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img7').style.display=''"></td></tr></table> <table id="Txt_img7" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img8').style.display=''"></td></tr></table> <table id="Txt_img8" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img9').style.display=''"></td></tr></table> <table id="Txt_img9" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img10').style.display=''"></td></tr></table> <table id="Txt_img10" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img11').style.display=''"></td></tr></table> <table id="Txt_img11" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img12').style.display=''"></td></tr></table> <table id="Txt_img12" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img13').style.display=''"></td></tr></table> <table id="Txt_img13" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img14').style.display=''"></td></tr></table> <table id="Txt_img14" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td><td width="30"></td><td><input type="button" name="Add_img_txt" value="Adauga link" onClick="document.getElementById('Txt_img15').style.display=''"></td></tr></table> <table id="Txt_img15" style="display: none"><tr><td><input type="text" name="Text_img" size="80"></td></tr></table><br/> Observatii:<br/> Daca aveti observatii/idei legate de imagini (amplasare, contur, text etc), le puteti scrie aici.<br/> Nu este un camp obligatoriu.<br/> <textarea name="Obs_img" cols="80" rows="7"></textarea><br/><br/><br/><br/> <input type="button" name="pag2_1" value="Pagina precedenta">     <input type="button" name="pag3_5" value="Continua comanda" disabled=true> </div> PS1: this code worked in firefox PS2: sorry for posting such a long code... This code works fine in IE but it won't in FF. The error console says topdiv.style and sidediv.style are 'undefined' This is the javascript: Code: function changeposition() { topdiv = "document.getElementById('top')"; sidediv = "document.getElementById('side')"; if (document.scrolltop > 100) { topdiv.style.position = "fixed"; topdiv.style.top = "-100px"; sidediv.style.position = "fixed"; sidediv.style.position = "35px"; } else { topdiv.style.position = "absolute"; topdiv.style.top = "0px"; sidediv.style.position = "absolute"; sidediv.style.position = "135px"; }} window.onscroll = changeposition(); and the HTML: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="standardstyle.css"> <script type="text/javascript" src="menuposition.js"></script> </head> <body> <div class="top" id="top"> ... </div> <div class="sidebar" id="side"> ... </div> ... </body> </html> I'm using FF4 Hi ALL, I am validating a three form field which takes temperature value between 0-50, humidity 1-100 & rainfall 0-200. I am able to see expected result for temperature value but not getting correct value for humidity & rainfall(still one can insert text in it..) Here is my code-: Code: <script type="text/javascript"> function validate_form(thisform) { with (thisform) { if (validate_required(obdate,"Date must be filled out!")==false) { obdate.focus();return false;} } is_leaf_fresh = -1; for (i=0;i < thisform.is_leaf_fresh.length; i++) { if (thisform.is_leaf_fresh[i].checked == true) { //alert("coming into "+thisform.is_leaf_fresh[i].checked); is_leaf_fresh = 1; } } if ((is_leaf_fresh == -1)) { alert("You must select an option for Fresh Leaf!"); return false; } var temp_max; temp_max = document.getElementById("temperature_max").value; if (temp_max != '' ) { var numericExpression = /^[0-9]+$/; if(temp_max.match(numericExpression) && (temp_max>=0 && temp_max<=50)){ return true; } else{ alert("Max Temperature value should be Numeric & between 0 to 50"); document.getElementById("temperature_max").focus(); return false; } } var temp_min; temp_min = document.getElementById("temperature_min").value; if (temp_min != '' ) { var numericExpression = /^[0-9]+$/; if(temp_min.match(numericExpression) && (temp_min>=0 && temp_min<=50)){ return true; } else{ alert("Min Temperature value should be Numeric & between 0 to 50!"); document.getElementById("temperature_min").focus(); return false; } } var rainfall_mm; rainfall_mm = document.getElementById("rainfall_mm").value; if (rainfall_mm != '' ) { var numericExpression = /^[0-9]+$/; if(rainfall_mm.match(numericExpression) && (rainfall_mm>=20 && rainfall_mm<=50)){ return true; } else{ alert("Min Temperature value should be Numeric & between 20 to 50!"); document.getElementById("rainfall_mm").focus(); return false; } } var humidity_mm; humidity_mm = document.getElementById("humidity_mm").value; if (humidity_mm != '' ) { var numericExpression = /^[0-9]+$/; if(humidity_mm.match(numericExpression) && (humidity_mm>=20 && humidity_mm<=50)){ return true; } else{ alert("Min Temperature value should be Numeric & between 20 to 50!"); document.getElementById("humidity_mm").focus(); return false; } } } </script> Thanks in Advance!! Hello all, I am trying to use document.getElementById in FF but its not working. There is a main page. in that mainpage there is a iframe and in that iframe (id = DocFrame) there is a textbox (id="fileuploadedcnt") which i am trying to access. there is no error. ofcourse i have given name and id to the textbox. Below is the code function ConfirmCertificate(id , Project_ID , Subprogram_ID , ITCType_TI) { frm=document.mainform; //fileuploadedcnt = (document.frames("DocFrame").document.forms("upload_form").elements("fileuploadedcnt").value); filecntobj = (document.getElementsByName("fileuploadedcnt")); filecntobj = (document.getElementById("fileuploadedcnt")); alert(fileuploadedcnt); alert((filecntobj.value)); return; if (fileuploadedcnt>0) { result=confirm("Are you sure you want to confirm this certificate? "); } In the abpve case i tried both the name and id properties. with Name property i get the HTMLObj alert but again it fails if i attach value method. And for id, it doesnt work at all No errors ofcourse in both the cases What am i missing Thanks Please see the "watching eyes" next to the search box at the top of: http://www.burton.com I am looking to recreate a similar effect for a project, and I cannot figure out what script is running this. I can see there is some CSS and JS associated with this file but I cannot seem to figure out how it works. It seems to be done using x,y coordinates. Any help would be greatly appreciated. Thank you in advance, Jim I'm working on my own site for layouts for sites like Myspace and Ning. Myspace changed their layouts to no longer include CSS so I am working on a new way to post their layouts. I used this same method to post all our other layouts. For some reason this is not showing up in IE. Firefox: IE: Interestingly enough, when I run the debugger in IE it loads when it is done. If not I get the black hole effect above. ERRORS: Object required Not implemented Any help will be greatly appreciated! Code: bgImg = document.getElementById('bg').innerHTML; tile = document.getElementById('bgtile').innerHTML; att = document.getElementById('bgatt').innerHTML; pos = document.getElementById('bgpos').innerHTML; top = document.getElementById('mar').innerHTML; ht = document.getElementById('marht').innerHTML; alink = document.getElementById('sel').innerHTML; col = document.getElementById('bgcol').innerHTML; hed = document.getElementById('hdr').innerHTML; bord = document.getElementById('bdr').innerHTML; con = document.getElementById('ct').innerHTML; div3 = document.getElementById('MS3css').innerHTML; if (document.getElementById('bg')){ document.getElementById('bgimgEmpty').innerHTML='Background Image: <br /><textarea id="MS3" style="width:250px; height: 55px; background: #999999; color: #000000; padding: 2px;" onclick="select()" ><img src="'+bgImg+'"></textarea><br />';} if (document.getElementById('bgtile')){ document.getElementById('bgtileEmpty').innerHTML='Background Tile: <br /><textarea id="MS3" style="width:250px; height: 25px; background: #999999; color: #000000; padding: 2px;" onclick="select()" >'+tile+'</textarea><br />';} if (document.getElementById('bgatt')){ document.getElementById('bgattEmpty').innerHTML='Background Attachment: <br /><textarea id="MS3" style="width:250px; height: 25px; background: #999999; color: #000000; padding: 2px;" onclick="select()" >'+att+'</textarea><br />';} if (document.getElementById('bgpos')){ document.getElementById('bgposEmpty').innerHTML='Background Position: <br /><textarea id="MS3" style="width: 250px; height: 25px; background: #999999; color: #000000; padding: 2px;" onclick="select()" >'+pos+'</textarea><br />';} if (document.getElementById('mar')){ document.getElementById('marEmpty').innerHTML='Marquee: <br /><textarea id="MS3" style="width:250px; height: 55px; background: #999999; color: #000000; padding: 2px;"><a href="http://skemaholicsanonymous.com/"><img src="'+top+'"></a></textarea><br />';} if (document.getElementById('marht')){ document.getElementById('marhtEmpty').innerHTML='Marquee Height: <br /><textarea id="MS3" style="width:60px; height: 25px; background: #999999; color: #000000; padding: 2px;" onclick="select()" >'+ht+'</textarea><br />';} if (document.getElementById('sel')){ document.getElementById('selEmpty').innerHTML='Selected: <br /><textarea id="MS3" style="width:60px; height: 25px; background: #999999; color: #000000; padding: 2px;" onclick="select()" >'+alink+'</textarea><br />';} if (document.getElementById('bgcol')){ document.getElementById('bgcolEmpty').innerHTML='Background Color: <br /><textarea id="MS3" style="width:60px; height: 25px; background: #999999; color: #000000; padding: 2px;" onclick="select()" >'+col+'</textarea><br />';} if (document.getElementById('hdr')){ document.getElementById('hdrEmpty').innerHTML='Header: <br /><textarea id="MS3" style="width:60px; height: 25px; background: #999999; color: #000000; padding: 2px;" onclick="select()" >'+hed+'</textarea><br />';} if (document.getElementById('bdr')){ document.getElementById('bdrEmpty').innerHTML='Borders: <br /><textarea id="MS3" style="width:60px; height: 25px; background: #999999; color: #000000; padding: 2px;" onclick="select()" >'+bord+'</textarea><br />';} if (document.getElementById('ct')){ document.getElementById('ctEmpty').innerHTML='Content: <br /><textarea id="MS3" style="width:60px; height: 25px; background: #999999; color: #000000; padding: 2px;" onclick="select()" >'+con+'</textarea><br />';} if (document.getElementById('MS3css')){ document.getElementById('code2Empty').innerHTML='<form id="genDone"action="http://blog.skemaholicsanonymous.com/MSPreview3/preview.php" method="post" rel="nofollow" target="_blank"><textarea id="codebox" style="display: none;" name="genCode">'+div3+'</textarea><br /><input type="submit" value="Preview" id="prevLoad" /></form>';} Having so much trouble with this entire slideshow... but this is the most recent development. For some reason the opacity change and border styles are not being added to the current thumbnail div that is selected, controlled by this code: Code: var current = 0; function swapimg( show ){ var piece = new Array(); piece[0] = '../assets/images/windycity/windycity01.gif'; title[0] = '[ Winners Paint the Town Red. Loosers Supply the Blood. ]'; piece[1] = '../assets/images/windycity/windycity02.gif'; title[1] = '[ One way or another they’re leaving on wheels. ]'; document.getElementById( 'featured' ).src = piece[show]; document.getElementById( 'featured' ).alt = title[show]; for( i = 0; i < meta.length; i++ ){ document.getElementById( 'item' + i ).style.opacity = '.5'; document.getElementById( 'item' + i ).style.border = 'solid 2px #2b2b2d'; } document.getElementById( 'item' + ( show ) ).style.opacity = '.99'; document.getElementById( 'item' + ( show ) ).style.border = 'solid 2px #0597af'; current = ( show ); And this is the html that it should be controlling: Code: <div class="thumbs"> <div class="listimg"><span onclick="swapimg(0);" ><img id="item0" src="../assets/images/windycity/windycity01_thumb.jpg" alt="" style="opacity: .99; border:solid 2px #0597af"/></span></div> <div class="listimg"><span onclick="swapimg(1);" > <img id="item1" src="../assets/images/windycity/windycity02_thumb.jpg" alt="" /></span></div> <div class="listimg"><a href="javascript:swapimg(2);" ><img id="item2" src="../assets/images/windycity/windycity03_thumb.jpg" alt="" /></a></div> </div> Any help would be great- I've been staring at this so long all the code has jumbled together in my head, and as soon as I tackle one problem I find another! Thanks! Hi, So I think I can't see the trees for the forest. I'm pretty good at code and usually work out the answer myself. I am doing some work for a client, working on some code written by someone else. It is a form, and for some reason the validation isn't working. The form sends with or without data entered into the mandatory fields. I can't look at the code anymore.. Is this the correct place I would ask for help with such a thing? Thanks kindly. Hi guys, i m novice to javascript, i have a piece of code to preview the image after selecting it from file upload control,its working fine in Firefox,but its not working in IE,Chorome,what is the error please let me know,here is my code. function setImage(file) { if (document.all) document.getElementById("<%=prevImage.ClientID %>").src = file.value; else document.getElementById("<%=prevImage.ClientID %>").src = file.files.item(0).getAsDataURL(); if (document.getElementById("<%=prevImage.ClientID %>").src.length > 0) document.getElementById("<%=prevImage.ClientID %>").style.display = 'block'; } Hi, I am trying to show and hide different div objects on a webpage all with different ID's as you can see. Only the first object will work "('killstreakwin')", or any that is put first, none of the others work after that. It's not the HTML side, it's definatly the javascript function. I've tried to use a loop but I don't know how to implement it into something like this. Any help would be appreciated. This is the code I am using:- function windowOpen() { (document.getElementById('killstreakwin').style.visibility='visible'); (document.getElementById('standardwin').style.visibility='visible'); (document.getElementById('hardenedwin').style.visibility='visible'); (document.getElementById('veteranwin').style.visibility='visible'); (document.getElementById('prestigewin').style.visibility='visible'); (document.getElementById('perkswin').style.visibility='visible'); (document.getElementById('copycatwin').style.visibility='visible'); (document.getElementById('martyrdomwin').style.visibility='visible'); (document.getElementById('finalstandwin').style.visibility='visible'); (document.getElementById('painkillerwin').style.visibility='visible'); (document.getElementById('rankswin').style.visibility='visible'); (document.getElementById('prestigewin').style.visibility='visible'); (document.getElementById('primarywin').style.visibility='visible'); (document.getElementById('secondarywin').style.visibility='visible'); (document.getElementById('attachmentswin').style.visibility='visible'); } function windowClose() { (document.getElementById('killstreakwin').style.visibility='hidden'); (document.getElementById('standardwin').style.visibility='hidden'); (document.getElementById('hardenedwin').style.visibility='hidden'); (document.getElementById('veteranwin').style.visibility='hidden'); (document.getElementById('prestigewin').style.visibility='hidden'); (document.getElementById('perkswin').style.visibility='hidden'); (document.getElementById('copycatwin').style.visibility='hidden'); (document.getElementById('martyrdomwin').style.visibility='hidden'); (document.getElementById('finalstandwin').style.visibility='hidden'); (document.getElementById('painkillerwin').style.visibility='hidden'); (document.getElementById('rankswin').style.visibility='hidden'); (document.getElementById('prestigewin').style.visibility='hidden'); (document.getElementById('primarywin').style.visibility='hidden'); (document.getElementById('secondarywin').style.visibility='hidden'); (document.getElementById('attachmentswin').style.visibility='hidden'); } Hey, I'm a total noob when it comes to javascript. and manged to make this code for a different forum: Code: //This script was created by TROPAFLIGHT2 var d=new Date(); var theDay=d.getDay(); switch (theDay) { case 1: document.write("<EMBED src="http://bit.ly/Ky9R5F" autostart=true loop=true volume=100 hidden=true>"); break; case 2: document.write("<EMBED src="http://bit.ly/Ky9R5F" autostart=true loop=true volume=100 hidden=true>"); break; case 3: document.write("<EMBED src="http://bit.ly/JGUdU9" autostart=true loop=true volume=100 hidden=true>"); break; case 4: document.write("<EMBED src="http://bit.ly/JMVvl0" autostart=true loop=true volume=100 hidden=true>"); break; case 5: document.write("<EMBED src="http://bit.ly/JVq7yb" autostart=true loop=true volume=100 hidden=true>"); break; case 6: document.write("<EMBED src="http://bit.ly/J7fvwY" autostart=true loop=true volume=100 hidden=true>"); break; default: document.write("<EMBED src="http://bit.ly/J2mc7a" autostart=true loop=true volume=100 hidden=true>"); } That code obviously didn't work so I manged to fix certain things: Code: //This script was created by TROPAFLIGHT2 var d=new Date(); var theDay=d.getDay(); switch (theDay) { case 1: document.write;"(<EMBED src="//bit.ly/Ky9R5F" autostart=true loop=true volume=100 hidden=true>)"; break; case 2: document.write;"(<EMBED src="//bit.ly/Ky9R5F" autostart=true loop=true volume=100 hidden=true>)"; break; case 3: document.write;"(<EMBED src="//bit.ly/JGUdU9" autostart=true loop=true volume=100 hidden=true>)"; break; case 4: document.write;"(<EMBED src="//bit.ly/JMVvl0" autostart=true loop=true volume=100 hidden=true>)"; break; case 5: document.write;"(<EMBED src="//bit.ly/JVq7yb" autostart=true loop=true volume=100 hidden=true>)"; break; case 6: document.write;"(<EMBED src="//bit.ly/J7fvwY" autostart=true loop=true volume=100 hidden=true>)"; break; default: document.write;"(<EMBED src="//bit.ly/J2mc7a" autostart=true loop=true volume=100 hidden=true>)"; } Problem is, it still doesn't work and I don't really know why. I've stared at it for a long time but the problem didn't click like last time. Any help at all would be appreciated. Thanks in advance, me. We have an ASP website which everything works fine in pre-IE8, firefox and even our iPhone browsers but not IE8. I know what the problem is and where the problem is but don't know how to fix it, it should be pretty simple but I am not a developer...just trying to fix this one problem When the page loads it is supposed to automatically fill in a text box with the word: No This is the javascript that is supposed to do that: Code: <script type="text/javascript"> function statusdefault(oSel) { status = 'No'; document.getElementById('theLabel5').value = status; } </script> and this shows the onload line: Code: <body onload="statusdefault(this)" bgcolor="#FFFFFF" background="images/background_stripe.jpg" text="#000000" link="#CCCCCC" vlink="#CCCCCC" alink="#CCCCCC" leftmargin="0" topmargin="10" marginwidth="0" marginheight="10"> <form action="<%=MM_editAction%>" method="POST" name="frmDetail" id="frmDetail"> additionally when someone changes a selection in one of the comboboxes it should change the textbox to: Yes Here is the code for that (which also does not work): Code: <script type="text/javascript"> function statusupdated(oSel) { status = 'Yes'; document.getElementById('theLabel5').value = status; } </script> which of course gets triggered by this: Code: <select name="lstQueue" id="select" onChange="statusupdated(this)"> This is the code for the said textbox: Code: <input name="txtStatusUpdated" type="text" id="theLabel5" value="<%=(rsQ.Fields.Item("StatusUpdated").Value)%>"> The error I get in IE8 is "This page cannot be displayed..." and give a http500 error with no other info. It looks like this javascript code was copied and pasted throughout this same ASP page and altered to do different things. All of the other scripts like this one work fine so I know it is just something in these particular ones that have a problem. Thanks for any help that can be given!!! Scott Hello, Im new to scripting. I have 2 scripts that work in firefox but not in ie. I was wondering if anyone could help me? The First Javascript Code: <SCRIPT language="javascript"> <!-- // ***** GET TOTAL function CalculateSum(setup, month, plan, form) { var A = parseFloat(setup); var B = parseFloat(month); form.x_amount.value = A + B; form.user5.value = plan; } --> </SCRIPT> The second javascript Code: var os_price = 0; var base_price = 0000; var total_carryover = 0000; function show_price() { features = 0; for(var pr in price) { features+=price[pr]; } month = features + base_price + os_price ; total = month + total_carryover; document.getElementById('setup_price').innerHTML="$"+(setup)/100; document.getElementById('monthly_price').innerHTML="$"+(month)/100; document.getElementById('total_price').innerHTML="$"+((total)/100+setup/100); } Thanks in advance for any help. i have a script that measures the window size and - at this point - only adjusts the width of one css element. first function: Quote: var myWidth = 0, myHeight = 0; function getWindowSize() { if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } // window.alert( 'Width = ' + myWidth ); // window.alert( 'Height = ' + myHeight ); } second function: Quote: //changecss JavaScript Functions by Shawn Olson //Copyright 2006-2008 //http://www.shawnolson.net function changecss(theClass,element,value,sheet) { //Last Updated on October 10, 1020 //documentation for this script at //http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html //ms: 5.5.11 added sheet: you have to point at the stylesheet by number var cssRules; var added = false; var mySheet = document.styleSheets[sheet]; if (mySheet['rules']) { cssRules = 'rules'; } else if (mySheet['cssRules']) { cssRules = 'cssRules'; } else { //no rules found... browser unknown } for (var R = 0; R < mySheet[cssRules].length; R++) { if (mySheet[cssRules][R].selectorText == theClass) { if(mySheet[cssRules][R].style[element]){ mySheet[cssRules][R].style[element] = value; added=true; break; } } } if(!added){ try{ mySheet.insertRule(theClass+' { '+element+': '+value+'; }',mySheet[cssRules].length); } catch(err){ try{mySheet.addRule(theClass,element+': '+value+';');}catch(err){} } } } i call the function in a php script that is to rule out that the server is talking to a mobile device, however, it echos javascript and a document ready function: Quote: $useragent=$_SERVER['HTTP_USER_AGENT']; if(preg_match('/android|...(non relevant code)...|zte\-/i',substr($useragent,0,4))) { echo '<link rel="stylesheet" type="text/css" href="1" />'; //the above never happens as i am testing on big screen } else { //echo '<link id="screensize" rel="stylesheet" type="text/css" href="stylesheet.php?cssid=47&mediatype=screen" />'; echo '<script type="text/javascript">'; echo '$(document).ready(function() { getWindowSize(); //ms: these variables come back: myWidth, myHeight if (myWidth >=1225) { changecss(".core-pageWidth","width","1225px",1); } else if (myWidth >1000) { myWidth=myWidth - 20; changecss(".core-pageWidth","width",myWidth+"px",1); } else if (myWidth >910) { myWidth=myWidth - 20; changecss(".core-pageWidth","width",myWidth+"px",1); } }); </script>'; } the changecss() does not work in https but works fine in http. is this to be expected? mario Hi there Im having an issue with some javascript that works fine in IE, but in FF is not working properly. The script is used to display a list of check boxes, the user can expand, which can checked to enabke a users selection of products. This is the script: Code: <script type="text/javascript"> var xcNode = []; // m = Parent UL ID // c = function xcSet(m, c, q, isCompletedLength) { if (document.getElementById && document.createElement) { var xs = m; m = document.getElementById(m).getElementsByTagName('ul'); var d, p, x, h, i, j; for (i = 0; i < q; i++) { var xp = document.getElementById("_" + xs + i); if (d = xp.getAttribute('id')) { if (navigator.userAgent.indexOf("Firefox") != -1) { var lstr = TrimTags((document.getElementById(xs).innerHTML)); xcCtrl(d, c, 'x', '[+] Click for more info', 'Show', 'Click to expand', lstr.length, isCompletedLength); x = xcCtrl(d, c, 'c', '[-] Click to Hide', 'Hide', 'Click to collapse', lstr.length, isCompletedLength); } else { xcCtrl(d, c, 'x', '[+] Click for more info', 'Show', 'Click to expand', (document.getElementById(xs).innerText).length, isCompletedLength); x = xcCtrl(d, c, 'c', '[-] Click to Hide', 'Hide', 'Click to collapse', (document.getElementById(xs).innerText).length, isCompletedLength); } p = xp.parentNode; if (h = !p.className) { j = 2; while ((h = !(d == arguments[j])) && (j++ < arguments.length)); if (h) { if (xp.name == parseURL()) { xp.style.display = 'block'; x = xcNode[d + 'c']; } else { xp.style.display = 'none'; x = xcNode[d + 'x']; } } } p.className = c; var expand = document.getElementById("expandBtn_" + xs + "0"); expand.insertBefore(x, expand.firstChild); } } } } works fine in IE, but not in Firefox where the expanded list is not showing the current number of items (checkboxes), it shows 34 check boxes in IE but only 17 in firefox. Thanks in advance Hi All, I am using one script which is functioning properly incase of IE but incase of Mozilla evenif the shift key is pressed and any character key is pressed then it is displaying Caps Lock is On. can anyone tell how can I make it Mozilla and IE compatible. Hey ! You know I'm now trying to use that light box embed contact form in my page http://uniwebmart.com/roshan and that fade in fade out effect as well which you can see now in LCD. But when I use the java script of that embed contact form in lightbox, my previous script of fading doesn't work. <script type="text/javascript" src="scripts/prototype.js"></script> <script type="text/javascript" src="scripts/lightbox.js"></script> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/fadeslideshow.js"></script> bold one is newly added script. Can't figure out the mistake. Can you please help me once again people??? |