JavaScript - Javascript And Style.backgroundimage Problems
Hi every1,
i am quite new to java-script programming. i created two images , one to display when during 'event.mouseout' and the other during mouseover Both images are the background images of a td element. I created a javascript : document.getElementById('bg_image').style.backgroundImage=url('sample.gif'); it works fine in Internet Explorer but doesnt in mozilla or opera thanx in advnc 4 any1 who wants ta help me. Similar TutorialsHi all, I've a set of similar elements (to display thumbnails) having style attributes like Code: style="background:#ddd url('/images/photos/thumbs/89625045.jpg') top center no-repeat;" Code: style="background:#ddd url('/images/photos/thumbs/708905 copy.jpg') top center no-repeat;" etc. I need to get the background-image urls from the style (and then remove the part thumbs). My intention is to dynamically create an img element corresponding to each thumbnail image. I was thinking to use a substr() to get the urls and replace() to remove "thumbs", but the property style.backgrounImage gives a string like Code: url("/images/photos/thumbs/4923face.jpg") in FF3, where as in FF2 and IE6 it gives Code: url(/images/photos/thumbs/4923face.jpg) . How can I proceed with this? Any help would be apreciated. Thanks. Hi i have a div box with some menu links as text. i need to change the background image of the whole div when i mouseover it and need to bring the original image when i mouseout it. i have used a javascript to do this. and here is my code <style type="text/css"> #test { background-image:url(home.gif); width:100%; } </style> <script type="text/javascript"> function changeBgImage (image, id) { var element = document.getElementById(id); element.style.backgroundImage = "url("+image+")"; } </script> <table width="100%" height="305" border="0" cellpadding="0" cellspacing="0" onMouseOver="changeBgImage('home1.gif', 'test1')" onMouseOut="changeBgImage(home.gif, 'test1')" id="test1"> this works fine but when i hover text links which is in the div, the background image flickers on mouseout in ie6. How to overcome this. Hi there, I have two textboxes and I want some images to be displayed in my textboxes randomly if randomNumber==1 let textbox1/textbox2 backgroundimage change and if randomnumber==2 let textbox1 backgroundimage change again. I think I need some fixing in the following lines: document.getElementById("txtbox1").Attributes.Add("this.style.backgroundImage = 'url(1.jpg)';"); Thanks for any help.. PHP Code: <script> setInterval("showimages()",500); function showimages() { var rno=Math.floor(Math.random()*2)+1; document.getElementById("box1").value=rno; if(rno==1){ document.getElementById("txtbox1").Attributes.Add("this.style.backgroundImage = 'url(1.jpg)';"); document.getElementById("txtbox2").Attributes.Add("this.style.backgroundImage = 'url(2.jpg)';"); } if(rno==2){ document.getElementById("txtbox1").Attributes.Add("this.style.backgroundImage = 'url(3.jpg)';"); document.getElementById("txtbox2").Attributes.Add("this.style.backgroundImage = 'url(4.jpg)';"); } } </script> <input type="text" id="txtbox1" style="position:absolute;top:200px;left:200px;height:150px"> <input type="text" id="txtbox2" style="position:absolute;top:200px;left:500px;height:150px"> <input type="text" id="box1" style="position:absolute;top:100px;left:100px;width:40px;"> <input type="button" onclick='location.reload()' style="position:absolute;top:20px;left:100px;"> // JavaScript Document function open_tab(el){ if(document.getElementById(el).style.display == "none"){ document.getElementById(el).style.display = "block"; } } function close_tab(el){ if(document.getElementById(el).style.display == "block"){ document.getElementById(el).style.display = "none"; } } Pretty basic code, works great in FireFox and Chrome in both HTML and ASPX pages. However in IE it only works properly in the .aspx pages. There are a series of links so when you click it hides the div's which are set to display:"block", except for one "div" which won't change to display"none" and I don't know why. hello, I need some help. I created a table that has some drop down boxes and based on the user selection it will show the text on the bottom, the plain drop down box has (nomal/bold/italic/bold-italic) the large drop down box has (large/medium/small) can someone please guide me or provide me a little demo on how to get this working?> thanks Hi guys, For some reason the following code is not working. Anybody see any issues? By default the style of #pricea in my stylesheet is visibility="hidden"; Code: <script type="text/javascript"> function arrow(boxName){ document.getElementById(boxName).style.visibility = "visible"; } </script> <?php if($_REQUEST['sort']=="price" && $_REQUEST['order']=="ASC"){ ?> <script type="text/javascript"> arrow('pricea'); </script> <?php }?> I have several checkboxes with labels, all laid out in a table. All of the checkboxes have a class of "hide" and through CSS I have them hidden. Then with javascript it's set up so that when a user clicks on the label for the checkbox the background of the TD that contains it changes colors to indicate that that item is selected. Works great except for those browsers that have javascript disabled. Then the form is useless. I'm thinking now it would be better to use javascript to apply the "hide" class to the checkboxes. That way if it's disabled then the checkboxes will still be visible and the form useable. I'm just not sure how to go about doing that (not much of a javascript ninja). Can anyone advise me on how to do that? I'd really appreciate the help! Thanks! Can anyone point out why this might not be working??? In my style sheet I have the span #downarrow display:none; Code: <script type="text/javascript"> function arrow(boxName){ document.getElementById(boxName).style.display = 'block'; } arrow('downarrow'); </script> <span id="downarrow"><img src="http://www.mysite.com/images/downarrow.png" /></span> Thanks!! This is how this page should work: click on an abbreviation and see player info to the immediate right of the green field. The left-most 'WR' and 'RB' in the upper portion of the field (imagemap) have javascript assigned to them. Click on these to test. So far, I get no player info but I do get this error: 'eleObj.style' is null or not an object Here's part of the html ... is the script call in the right place???? 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=iso-8859-1" /> <title>Diamond Bowl Depth Chart</title> <script type="text/javascript" src="http://juniorrank.com/depth/scripts/controls.js"></script> <script type="text/javascript" src="http://juniorrank.com/depth/scripts/event.js"></script> <link href="style.css" rel="stylesheet" type="text/css" /> </head> 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. Bear with me as this is my first post but i am not sure what this is about. My computer seems to have problems with its javascript when opening new windows from certain sites that are either audio or video files. I simply have not got a clue where to begin. Any help ould be most grateful. Hi All, As usual.. I'm not exactly sure what I am doing, I have the right ideas yet nothing is working how i want.. 1- Need the message "Welcome" to cycle through all different 20 styles I created 2- Need the message "Welcome to randomly cycle though all different styles I think I am over complicating this... And i lookeded over quite a number of times thinking I have it right.. I guess I don't since nothing is working Please note I have a separate css file called colors.css with 20 styles PHP Code: <html> <head> <title>Assignment 7</title> <link href="colors.css" rel="stylesheet" type="text/css"></link> <script> var index = 0; var randomindex = 0; function stylize() { index++; if (index > 20) index = 1; var s = "myStyle" + index; var e = "document.getElementsById("Text"); e.className = s; setTimeout("stylize()", 1500); return; } function random() { if (randomindex > 20) index = 1; var b = "myStyle" + randomindex; var c = "document.getElementsById("Text1"); c.className = b; randomindex = Math.floor(Math.random() * 20); document.getElementsbyId("Text1"); setTimeout("random()", 1500); return; } </script> </head> <body onLoad="stylize(); random()"> <table align="center" border="1" bordercolor="black"> <tr> <td align="center"> <font size="3"><b>Examples Below</b></font> </td> </tr> <tr> <td align="center" height="100" width="400"> <div id="Text" class="myStyle1"> Watch! </div> </tr> </table> <br><br> <table align="center" border="1" bordercolor="black"> <tr> <td align="center"> <font size="3"><b>Examples Below</b></font> </td> </tr> <tr> <td align="center" height="100" width="400"> <div id="Text1" class="myStyle1"> Welcome </div> </tr> </table> </body> </html> There's 2 problems i'm having with this code. 1. foodArray is a multidimensional array that is initialized with 13 elements at the start. When i load the page, the body onload event calls the fillTable function, which fills the table with the first 5 elements of foodArray. If i then click the next button in the bottom right corner, it shows the next 5 elements of foodArray by again calling the fillTable function, incrementing page variable by 1. If I press next a 3rd time it shows the last 3 items of foodArray, but it does not overwrite the last 2 rows of the output table that were filled with the previous second call to the fillTable function. This should happen because there are no elements in foodArray[13] and foodArray[14], and i tried to write the fillTable function to detect when the array is undefined and output dashes instead. How do i fix the fillTable function to overwrite these last 2 rows when the array is empty? the fillTable function seems to be crashing when it reaches these last 2 rows. 2. The second problem is simpler. Each add button in the table has a unique id defined by the fillTable function. When i click on one of these buttons, its supposed to call function add, which is supposed to turn the table cell with the add button clicked to a yellow background. what's wrong with it? Thanks in advance, G 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> <style type="text/css"> #content1 { position: absolute; right: 10px; z-index: 1; top: 100px; } </style> <link href="basicstyle.css" rel="stylesheet" type="text/css" /> <link href="advancestyle.css" rel="stylesheet" type="text/css" /> <link href="tablestyle.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> var food1 = new Array("-", "100% Parmesan Cheese", "Kraft", "Dairy & Alternatives", "2 Tbsp", "12g", 45, 2.5, 1.5, 0.1, 5, 230, 1, 0, 0, 5); var food2 = new Array("-", "100% Whole wheat bread", "Dempsters", "Grain Products", "2 slices", "71g", 180, 2, 0.5, 0, 0, 240, 33, 4, 3, 7); var food3 = new Array("-", "Canned Cut Asparagus", "Selection", "Fruit & Vegetables", "1/2 cup", "125mL", 25, 0.3, 0, 0, 0, 260, 4, 2, 2, 2); var food4 = new Array("-", "Chinese Fried Rice", "Uncle Ben's Fast & Fancy", "Grain Products", "1/4 package", "42g", 150, 0.5, 0.2, 0, 0, 370, 33, 1, 1, 3); var food5 = new Array("-", "Cooked Turkey Breast", "Pillar's", "Meat & Alternatives", "2 slices", "40g", 40, 0.5 ,0.3, 0, 20, 460, 1, 0, 1 ,8); var food6 = new Array("-", "Diet Coke", "Coke", "Beverages", "-", "250mL", 0, 0, 0, 0, 0, 35, 0, 0, 0, 0.1, "-"); var food7 = new Array("-", "Honey Nut O's Cereal", "Selection", "Grain Products", "3/4 cup", "30g", 120, 0.5, 0, 0, 0, 150, 26, 2, 12, 2); var food8 = new Array("-", "Hot dogs", "Schneider's", "Meat & Alternatives", "1 wiener", "37g", 120, 10, 3.5, 0.1, 20, 410, 2, 0, 0, 5); var food9 = new Array("-", "Milk Chocolate Crispie Joys", "Harry London", "Treats", "About 4", "40g", 190, 10, 6, 0, 5, 55, 26, "<1g", 18, 3); var food10 = new Array("-", "Mozzarella cheese", "Black Diamond", "Dairy & Alternatives", "1/4 inch cube", "30g", 110, 8, 5, 0.2, 25, 230, 1, 0, 0, 8); var food11 = new Array("-", "Pancake and Waffle Mix", "Selection", "Grain Products", "1/3 cup", "34g", 120, 1.5, 0.4, 0, 15, 510, 23, 1, 3, 3); var food12= new Array("-", "Rancher's Choice Calorie Wise", "Kraft", "Oils & Fats", "1 Tbsp.", "15mL", 35, 2.5, 0.4, 0, 5, 170, 3, 0, 1, 0.1); var food13 = new Array("-", "Strawberry Cereal Bars", "Selection", "Grain Products", "1 bar", "38g", 130, 2.5, 0.2, 0, 5, 210, 25, 3, 10, 2); var foodArray = [food1, food2, food3, food4, food5, food6, food7, food8, food9, food10, food11, food12, food13]; var resultArray = [ [ ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ] ]; var arrayToSearch = [ [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ] ]; var arrayRows; var arrayColumns; var outputTableRows; var outputTableColumns; var page = 1; var resultCount = 0; function fillTable( arr, p ) { //fill the output table with whatever array is passed to it in form of arr parameter. outputTableRows = 5; outputTableColumns = 16; for (var x = 0; x < outputTableRows; x++) { var xPage = (x + 5 * (p - 1)); for (var y = 0; y < outputTableColumns; y++) { //set id variable in order to refer to each cell in the output table by this id. var id = x + "_" + y; if ( (arr[xPage][y] != undefined) ) { //if its the first column, put in a button, or else put in the resultArray[x][y] value in the output table cell. if (y == 0) document.getElementById(id).innerHTML = "<input id=\"b" + id + "\" type=\"button\" value=\"add\" onclick=\"add()\">"; else document.getElementById(id).innerHTML = arr[xPage][y]; //else if the resultArray entry is undedefined, just put in a dash in the output table cell. } else { document.getElementById(id).innerHTML = "-"; } } } } // why wont this work???????????????????????????????????????? function add( e ) { alert("Add"); if (!e) var e = window.event; var callerId = this.id; alert(callerId); this.parent.style.backgroundColor = "yellow"; } function searchArray() { //search the array containing all database food items (foodArray), a 2 dimensional array. //find array entries that match search results. //put search results into 2 dimesional array foodArray. //display foodArray in output table. //re-intitialize resultArray to empty it, and resultCount to 0. var resultArray = [ [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ] ]; var arrayToSearch = [ [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ], [ , ] ]; resultCount = 0; page = 1; //get search terms. food = document.getElementById("foodsearch").value; brand = document.getElementById("brandsearch").value; foodType = document.getElementById("foodtypesearch").value; //set rows and columns dynamiically and for the output table //this uses foodArray to start. //only works if all rows of foodArray have the correct length, because always uses the first row to count length. arrayRows = foodArray.length; arrayColumns = foodArray[0].length; outputTableRows = 5; outputTableColumns = 16; //if a search term is entered for food if (food != "") { //for each row in the foodArray table for (var x = 0; x < arrayRows; x++) { //search the second column of each foodArray item for the search term. var result = foodArray[x][1].indexOf(food); //if a match was found, put the result into a new row for resultArray referred to by resultCount. if (result != -1) { for (var y = 0; y < arrayColumns; y++) { resultArray[resultCount][y] = foodArray[x][y]; } resultCount += 1; } } fillTable( resultArray, page ); } //if a search term is entered for brand if (brand != "") { //for each row in the foodArray table for (var x = 0; x < arrayRows; x++) { //search the second column of each foodArray item for the search term. var result = foodArray[x][2].indexOf(brand); //if a match was found, put the result into a new row for resultArray referred to by resultCount. if (result != -1) { for (var y = 0; y < arrayColumns; y++) { resultArray[resultCount][y] = foodArray[x][y]; } resultCount += 1; } } fillTable ( resultArray, page ); } //if a search term is entered for foodType if (foodType != "") { //for each row in the foodArray table for (var x = 0; x < arrayRows; x++) { //search the second column of each foodArray item for the search term. var result = foodArray[x][3].indexOf(foodType); //if a match was found, put the result into a new row for resultArray referred to by resultCount. if (result != -1) { for (var y = 0; y < arrayColumns; y++) { resultArray[resultCount][y] = foodArray[x][y]; } resultCount += 1; } } fillTable ( resultArray, page ); } } function resetSearch() { page = 1; fillTable ( foodArray, page ); document.getElementById("foodsearch").value = ""; document.getElementById("brandsearch").value = ""; document.getElementById("foodtypesearch").value = ""; } function start() { alert("Start pressed"); page = 1; fillTable ( foodArray, page ); } function last() { alert("Last"); page -= 1; fillTable ( foodArray, page ); } function next() { alert("Next"); page += 1; fillTable ( foodArray, page ); } function end() { alert("End"); page = 3; fillTable ( foodArray, page ); } </script> </head> <body onload="fillTable( foodArray, 1 )"> <div id="dcontainer" class="type3div"> <div id="dheader" class="type2div"> <div id="dlogo" class="type1div"></div> <div id="dlogin" class="type1div"></div> </div> <div id="dmenubar" class="type2div"> <a href=""><div id="dmenu1" class="navigation">Page 1</div></a> <a href=""><div id="dmenu2" class="navigation">Page 2</div></a> <a href=""><div id="dmenu3" class="navigation">Page 3</div></a> <a href=""><div id="dmenu4" class="navigation">Page 4</div></a> <a href=""><div id="dmenu5" class="navigation">Page 5</div></a> </div> <div id="dcontent" class="type2div"> <h1>Grocery Store Aisle 1: Select food items from a database</h1> <div id="content1" class="type1div"> <div id="legend"> <table border="1"> <tr> <td colspan="2" align="center"><b>Legend</b></td> </tr> <tr> <td>SS = Serving Size</td><td>Sod = Sodium</td> </tr> <tr> <td>Cal = Calories</td><td>Carb = Carbohydrate</td> </tr> <tr> <td>Fat = Fat</td><td>Fib = Carbohydrate: Fibre</td> </tr> <tr> <td>Sat = Fat: Saturated</td><td>Sug = Carbohydrate: Sugars</td> </tr> <tr> <td>Trans = Fat: Trans</td><td>Pro = Protein</td> </tr> <tr> <td>Chol = Cholesterol</td><td style="background-color: yellow">Items in yellow are already in your fridge</td> </tr> </table> </div> </div> <div id="content2" class="type1div"> <div id="search"> <h2>Search Aisle 1</h2> <form id="form1" name="form1" method="post" action=""> <table border="1"> <tr> <td>Food:</td> <td><input id="foodsearch" type="text" size="30" /></td> </tr> <tr> <td>Brand:</td> <td><input id="brandsearch" type="text" size="30" /></td> </tr> <tr> <td>Food Type:</td> <td><input id="foodtypesearch" type="text" size="30" /></td> <tr> <td colspan="2" align="right"> <input id="resetsearch" type="button" size="20" value="Reset Search" onclick="resetSearch()" /> <input id="gosearch" type="button" size="20" value="Search" onclick="searchArray()" /> </td> </tr> </table> </form> </div> </div> <div id="content3" class="type1div"> <h2>Results</h2> <div id="table1" class="outputTable"> <table border="1"> <thead> <tr> <th class="tableHeadMediumCenter">Edit</th> <th class="tableHeadLargeLeft">Food</th> <th class="tableHeadLargeLeft">Brand</th> <th class="tableHeadLargeLeft">Food Type</th> <th class="tableHeadLargeLeft">Serving Amount</th> <th class="tableHeadSmallCenter">SS</th> <th class="tableHeadSmallCenter">Cal</th> <th class="tableHeadSmallCenter">Fat</th> <th class="tableHeadSmallCenter">Sat</th> <th class="tableHeadSmallCenter">Trans</th> <th class="tableHeadSmallCenter">Chol</th> <th class="tableHeadSmallCenter">Sod</th> <th class="tableHeadSmallCenter">Carb</th> <th class="tableHeadSmallCenter">Fib</th> <th class="tableHeadSmallCenter">Sug</th> <th class="tableHeadSmallCenter">Pro</th> </tr> </thead> <tbody> <tr> <td id="0_0" class="tableCellCenterTop">-</td> <td id="0_1" class="tableCellLeftTop">-</td> <td id="0_2" class="tableCellLeftTop">-</td> <td id="0_3" class="tableCellLeftTop">-</td> <td id="0_4" class="tableCellLeftTop">-</td> <td id="0_5" class="tableCellCenterTop">-</td> <td id="0_6" class="tableCellCenterTop">-</td> <td id="0_7" class="tableCellCenterTop">-</td> <td id="0_8" class="tableCellCenterTop">-</td> <td id="0_9" class="tableCellCenterTop">-</td> <td id="0_10" class="tableCellCenterTop">-</td> <td id="0_11" class="tableCellCenterTop">-</td> <td id="0_12" class="tableCellCenterTop">-</td> <td id="0_13" class="tableCellCenterTop">-</td> <td id="0_14" class="tableCellCenterTop">-</td> <td id="0_15" class="tableCellCenterTop">-</td> </tr> <tr> <td id="1_0" class="tableCellCenterTop">-</td> <td id="1_1" class="tableCellLeftTop">-</td> <td id="1_2" class="tableCellLeftTop">-</td> <td id="1_3" class="tableCellLeftTop">-</td> <td id="1_4" class="tableCellLeftTop">-</td> <td id="1_5" class="tableCellCenterTop">-</td> <td id="1_6" class="tableCellCenterTop">-</td> <td id="1_7" class="tableCellCenterTop">-</td> <td id="1_8" class="tableCellCenterTop">-</td> <td id="1_9" class="tableCellCenterTop">-</td> <td id="1_10" class="tableCellCenterTop">-</td> <td id="1_11" class="tableCellCenterTop">-</td> <td id="1_12" class="tableCellCenterTop">-</td> <td id="1_13" class="tableCellCenterTop">-</td> <td id="1_14" class="tableCellCenterTop">-</td> <td id="1_15" class="tableCellCenterTop">-</td> </tr> <tr> <td id="2_0" class="tableCellCenterTop">-</td> <td id="2_1" class="tableCellLeftTop">-</td> <td id="2_2" class="tableCellLeftTop">-</td> <td id="2_3" class="tableCellLeftTop">-</td> <td id="2_4" class="tableCellLeftTop">-</td> <td id="2_5" class="tableCellCenterTop">-</td> <td id="2_6" class="tableCellCenterTop">-</td> <td id="2_7" class="tableCellCenterTop">-</td> <td id="2_8" class="tableCellCenterTop">-</td> <td id="2_9" class="tableCellCenterTop">-</td> <td id="2_10" class="tableCellCenterTop">-</td> <td id="2_11" class="tableCellCenterTop">-</td> <td id="2_12" class="tableCellCenterTop">-</td> <td id="2_13" class="tableCellCenterTop">-</td> <td id="2_14" class="tableCellCenterTop">-</td> <td id="2_15" class="tableCellCenterTop">-</td> </tr> <tr> <td id="3_0" class="tableCellCenterTop">-</td> <td id="3_1" class="tableCellLeftTop">-</td> <td id="3_2" class="tableCellLeftTop">-</td> <td id="3_3" class="tableCellLeftTop">-</td> <td id="3_4" class="tableCellLeftTop">-</td> <td id="3_5" class="tableCellCenterTop">-</td> <td id="3_6" class="tableCellCenterTop">-</td> <td id="3_7" class="tableCellCenterTop">-</td> <td id="3_8" class="tableCellCenterTop">-</td> <td id="3_9" class="tableCellCenterTop">-</td> <td id="3_10" class="tableCellCenterTop">-</td> <td id="3_11" class="tableCellCenterTop">-</td> <td id="3_12" class="tableCellCenterTop">-</td> <td id="3_13" class="tableCellCenterTop">-</td> <td id="3_14" class="tableCellCenterTop">-</td> <td id="3_15" class="tableCellCenterTop">-</td> </tr> <tr> <td id="4_0" class="tableCellCenterTop">-</td> <td id="4_1" class="tableCellLeftTop">-</td> <td id="4_2" class="tableCellLeftTop">-</td> <td id="4_3" class="tableCellLeftTop">-</td> <td id="4_4" class="tableCellLeftTop">-</td> <td id="4_5" class="tableCellCenterTop">-</td> <td id="4_6" class="tableCellCenterTop">-</td> <td id="4_7" class="tableCellCenterTop">-</td> <td id="4_8" class="tableCellCenterTop">-</td> <td id="4_9" class="tableCellCenterTop">-</td> <td id="4_10" class="tableCellCenterTop">-</td> <td id="4_11" class="tableCellCenterTop">-</td> <td id="4_12" class="tableCellCenterTop">-</td> <td id="4_13" class="tableCellCenterTop">-</td> <td id="4_14" class="tableCellCenterTop">-</td> <td id="4_15" class="tableCellCenterTop">-</td> </tr> </tbody> </table> </div> <div id="scroll"> <span onclick="start()">‹‹Start</span> <span onclick="last()">‹Last</span> <span onclick="next()">Next›</span> <span onclick="end()">End››</span> </div> </div> </div> </div> </body> </html> I'm currently in the process of updating our old website as the layout is just terrible and it's hard to find products on it. This new layout has drop down menus, accordion menus and an image enlarger all from JavaScript. They work wonders in Firefox and Google chrome but, as usual, Internet Explorer has decided not to load it right for me. I've got several problems... Images won't show up most of the time Not able to click on linked images and the links from the drop down menu Accordion menu won't work, it just displays as one long sidebar When it does work, it shows a big gap between each main header rather than keeping them close together The drop list from the drop down menu hides behind the accordion menu Is there anything I can do that makes IE accept the javascripts? Unfortunately the new layout isn't up live so I've nothing you can link to. However, if there's any coding that you need I'll be more than happy to post it on. Thanks for your time! Hi and firstly thank you in advance as I've just joined this forum in search of technical help. I am working on a website and having some problems with javascript that creates tabbed content on a page. The script is a free script from http://nuevvo.com/labs/simpletabs/. The problem is that the page with the script is not showing properly. The issue seems to only happen in Internet Explorer. The site was created on a development server and then copied over to the current hosting. The page appeared fine on the development server but when transferred to the new server the problem showed up. Please look at the following in Internet Explorer: This is how the page should look: http://www.sourcescotland.com/nobles...ing-times.html But on the new server it looks like this: http://www.galleyoflorne.co.uk/noble...ing-times.html The code is he Code: <script type="text/javascript" src="scripts/simpletabs_1.3.packed.js"></script> The actual code file is he http://www.galleyoflorne.co.uk/noble..._1.3.packed.js I would be willing to offer paid help if this is necessary. Or at least get to know you so that I can offer you work in future. I don't have anyone on my team yet that specialises in Javascript. thanks so much, Deb Hey guys, im a bit of a loser with Javascript and need a bit of validation done but I have no idea what the problem is with my code, can anyone help? Form: Code: <div id="Layer3"> <form id="form" name="form" method="post" onsubmit='return formValidator(form)' action="Candidate output.php"> <p class="style3"><u>Search for a Candidate </u></p> <p class="style3">Candidate ID <input type="text" name="CandidateID" /> </p> <p class="style3">File <select name="File"> <option>--Select--</option> <option>To be deleted</option> </p> <p class="style3">Name <input type="text" name="Name" /> </p> <p class="style3">Current Job Title <select name="Current_Job_title"> <option>--Select--</option> <option>Accessories</option> </select> </p> <p class="style3">Contact Telephone <input type="text" name="Contact_Telephone" /> </p> <p class="style3">Contact Email <input type="text" name="Contact_Email" /> </p> <p class="style3">Town <input type="text" name="Town" /> </p> <p class="style3">County <select name="County"> <option>--Select--</option> <option>Aberdeenshire</option> </select> </p> <p class="style3">Postcode <input type="text" name="Postcode" /> </p> <p class="style3">Languages spoken <input type="text" name="Languages_Spoken" /> </p> <p class="style3">Previous Job Title <select name="Job_Title" > <option>--Select--</option> <option>Accessories</option> </select> </p> <p class="style3">Previous Employer <input type="text" name="Employer" /> </p> <p class="style3">Previous Employment Type <select name="Employment_Type"> <option>--Select--</option> <option>Manufacturer</option> </select> </p> <p class="style3">Previous Department Type <select name="Department_type"> <option>--Select--</option> <option>Accounts</option> </select> </p> <p class="style3">Order By <select name="Order_By"> <option>--Select--</option> <option>CandidateID</option> </select> <input type="checkbox" name="Desc" value="y" /> Decending (Ascending leave unchecked) </p> <p class="style3"> <input type="submit" name="Submit" value="Submit" /> </p> </form> </div> Validation in the <Head>; <script language="JavaScript" type='text/javascript'> function formValidator(form){ // Make quick references to our fields var CandidateID = document.getElementById('CandidateID'); var Name = document.getElementById('Name'); var Contact_T = document.getElementById('Contact_Telephone'); var Contact_E = document.getElementById('Contact_Email'); var Town = document.getElementById('Town'); var Postcode = document.getElementById('Postcode'); var Ls = document.getElementById('Languages_Spoken'); var P_Employer = document.getElementById('Previous_Employer'); /*http://www.tizag.com/javascriptT/javascriptform.php*/ // Check each input in the order that it appears in the form! if(isNumeric(CandiateID, "Please enter numbers only")){ if(isAlphabet(Name, "Please enter letters only")){ if(isNumeric(Contact_T, "Please enter numbers only")){ if(lengthrestriction(Contact_T, 11)){ if(emailValidator(Contact_E, "Please enter a valid email address")){ if(isAlphabet(Town, "Please enter letters only")){ if(postit(Postcode, "Please enter a valid Postcode")){ if(isAlphabet(LS, "Please enter letters only")){ if(isAlphabet(P_Employer, "Please enter letters only")){ return true; } } } } } } } } } return false; function isNumeric(elem, alerttxt){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(alerttxt); elem.focus(); return false; } } function isAlphabet(elem, alerttxt){ var alphaExp = /^[a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(alerttxt); elem.focus(); return false; } } function isAlphanumeric(elem, alerttxt){ var alphaExp = /^[0-9a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(alerttxt); elem.focus(); return false; } } function lengthRestriction(elem, max){ var uInput = elem.value; if(uInput.length >= uInput.length <= max){ return true; }else{ alert("Please enter between 0 and " +max+ " characters"); elem.focus(); return false; } } function emailValidator(elem, alerttxt){ var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; if(elem.value.match(emailExp)){ return true; }else{ alert(alerttxt); elem.focus(); return false; } } function postit(elem, alerttxt){ //check postcode format is valid test = document.details.Postcode.value; size = test.length test = test.toUpperCase(); //Change to uppercase while (test.slice(0,1) == " ") //Strip leading spaces {test = test.substr(1,size-1);size = test.length } while(test.slice(size-1,size)== " ") //Strip trailing spaces {test = test.substr(0,size-1);size = test.length } document.details.Postcode.value = test; //write back to form field if (size < 6 || size > 8){ //Code length rule alert(test + " is not a valid postcode - wrong length"); document.details.Postcode.focus(); return false; } if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule alert(test + " is not a valid postcode - cannot start with a number"); document.details.Postcode.focus(); return false; } if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule alert(test + " is not a valid postcode - alpha character in wrong position"); document.details.Postcode.focus(); return false; } if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule alert(test + " is not a valid postcode - number in wrong position"); document.details.Postcode.focus(); return false; } if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule alert(test + " is not a valid postcode - number in wrong position"); document.details.Postcode.focus(); return false; } if (!(test.charAt(size-4) == " ")){//space in position length-3 rule alert(test + " is not a valid postcode - no space or space in wrong position"); document.details.Postcode.focus(); return false; } count1 = test.indexOf(" ");count2 = test.lastIndexOf(" "); if (count1 != count2){//only one space rule alert(test + " is not a valid postcode - only one space allowed"); document.details.Postcode.focus(); return false; } alert("Postcode Format OK"); return true; } </script> Im sure there are a few syntax errors but any and all help is greatly appreciated sorry for my poor english I have 2 boxfield in my search engine...when i write somthing on my 1st text box and press the clear button it clear me the thing i wrote in the text field.... when i write somthing and drag it from 1st text box to the 2nd and then press the clear button.the letter in the 2nd textfield jump the 1st one.....and doesnt clear herself... what can couse it ? I am having a problem with the follow code with IE9 only. Works fine with any other browser.. Any help? Thanks <a href="javascript:var w = window.open('show_photo.php?ad_id={AD_ID}&img_id={IMG_ID}','','width=450,height=500,toolbar=0,scroll bars=0,statusbar=0,menubar=0,resizable=0');"> </a> |