JavaScript - Aptabs Script : 3 Problems
Similar Tutorialsi need the tab script to be horisontal and vertical both 100% of the browser screen, no mater what are the user screen resolutions are if i change the width and height to 100% it wont work 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>apTabs</title> <script type="text/javascript" src="lib/prototype.js"></script> <script type="text/javascript" src="src/aptabs.js"></script> <link rel="stylesheet" type="text/css" href="css/aptabs.css" /> </head> <body> <div id="apTabs" class="apTabs" style="width:500px; height:200px "> <h2>Tab 1</h2> <div>Tab content 1. Select 2nd tab by <a href="#" onclick="apTabs.show('apTabs', 2);return false">clicking here.</a><br /><br /> This script featured on <a href="http://www.javascriptkit.com">JavaScript Kit</a>.</div> <h2>Tab 2</h2> <div>Tab content 2. Select 3rd tab by <a href="#" onclick="apTabs.show('apTabs', 3);return false">clicking here.</a></div> <h2 class="noclose">Tab 3</h2> <div>Tab content 3. Notice how this tab cannot be user closed. Select 4th tab by <a href="#" onclick="apTabs.show('apTabs', 4);return false">clicking here.</a></div> <h2>Tab 4</h2> <div>Tab content 4. Select 5th tab by <a href="#" onclick="apTabs.show('apTabs', 5);return false">clicking here.</a></div> <h2>Tab 5</h2> <div>apTabs has been successfully tested in IE6-7, Opera9, Chrome 0.3, Safari 3.1 Win, and Firefox 2-3.</div> </div> <p><a href="javascript:void(0)" onclick="apTabs.add('apTabs', {title: 'Ajax', ajax: 'ajax.php'})">Create a new tab "Ajax" with Ajax content</a></p> <p><a href="javascript:void(0)" onclick="apTabs.add('apTabs', {title: 'iFrame', iframe: 'iframe.html'})">Create a new tab "iFrame" with iFrame content</a></p> <p>This script available at <a href="http://www.javascriptkit.com">JavaScript Kit</a></p> </body> </html> I'm using ApTabs. My problem is long pageload times because I have IFrames as DIV content. How can I make "IFrame Tabs" so pages load when tabs are click instead of preloading?
Hello all, I'm back with more silly newbie questions. I'm building a website that includes 3 javascript codes: 1. Onmouseover image switch for the nav bar. 2. On a specific page, onmouseover display of hidden divs. 3. Particletree's Dynamic Resolution Dependent Layout script (http://particletree.com/features/dyn...ndent-layouts/) All three scripts work fine in firefox, but the 2nd script doesn't work in safari and chrome, and the 3rd one doesn't work in safari, chrome and IE(8). Since the 1st one works fine in all browsers, I'm guessing this isn't a problem with my javascript link or anything like that. The website is: www.sheket.co.il/index4.html The specific page that runs the 2nd code is: www.sheket.co.il/services.html My javascript is: http://www.sheket.co.il/javascript.js And my default stylesheet is: http://www.sheket.co.il/style.css (I apologize for possible jibrish- the website is in Hebrew...) Any help with these two problems would be greatly appreciated! Evening all, I am new here and seeking some helping modifying this existing code that I found so that it will allow me to run 3 scrollers within the same page. I have tried to rename the variables and other elements within the script but still no luck.... I appreciate the responses: Code: <script type="text/javascript"> var goleftimage='images/left_arrow_1.jpg' var gorightimage='images/right_arrow_1.jpg' var menuwidth=380 var menuheight=60 var scrolldir="normal" var scrollspeed=6 var menucontents='<nobr><center>SCROLLING CONTENT HERE</center></nobr>' var iedom=document.all||document.getElementById var rightdircode='onMouseover="moveleft()" onMouseout="clearTimeout(lefttime)"' var leftdircode='onMouseover="moveright()" onMouseout="clearTimeout(righttime)"' if (scrolldir=="reverse"){ var tempswap=leftdircode leftdircode=rightdircode rightdircode=tempswap } if (iedom) document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-5000">'+menucontents+'</span>') var actualwidth='' var cross_scroll, ns_scroll var loadedyes=0 function fillup(){ if (iedom){ cross_scroll=document.getElementById? document.getElementById("test2") : document.all.test2 cross_scroll.innerHTML=menucontents actualwidth=document.all? cross_scroll.offsetWidth : document.getElementById("temp").offsetWidth } else if (document.layers){ ns_scroll=document.ns_scrollmenu.document.ns_scrollmenu2 ns_scroll.document.write(menucontents) ns_scroll.document.close() actualwidth=ns_scroll.document.width } loadedyes=1 } window.onload=fillup function moveleft(){ if (loadedyes){ if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth)){ cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px" } else if (document.layers&&ns_scroll.left>(menuwidth-actualwidth)) ns_scroll.left-=scrollspeed } lefttime=setTimeout("moveleft()",50) } function moveright(){ if (loadedyes){ if (iedom&&parseInt(cross_scroll.style.left)<0) cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px" else if (document.layers&&ns_scroll.left<0) ns_scroll.left+=scrollspeed } righttime=setTimeout("moveright()",50) } if (iedom||document.layers){ with (document){ write('<table border="0" cellspacing="0" cellpadding="1">') write('<td valign="middle"><a href="#" '+leftdircode+'><img src="'+goleftimage+'"border=0></a> </td>') write('<td width="'+menuwidth+'px" valign="top">') if (iedom){ write('<div style="position:relative;width:'+menuwidth+'px;height:'+menuheight+'px;overflow:hidden;">') write('<div id="test2" style="position:absolute;left:0;top:0">') write('</div></div>') } else if (document.layers){ write('<ilayer width='+menuwidth+' height='+menuheight+' name="ns_scrollmenu">') write('<layer name="ns_scrollmenu2" left=0 top=0></layer></ilayer>') } write('</td>') write('<td valign="middle"> <a href="#" '+rightdircode+'>') write('<img src="'+gorightimage+'"border=0></a>') write('</td></table>') } } </script> I will include this within a php page and the menu contents will be dynamically pulled from a database, I can handle populating the menucontents however, I have failed to be able to have more than one scroller on the page at once. Thanks Hi All, I have two scripts which I want to try and integrate. I am using a nice gallery script to show thumbnails which are appended to a an image wrapper which on click of the thumbnail shows the larger image in the image wrapper, I am trying to implement cloud zoom which is a plugin which uses image srcs to then point to an anchor href to show another larger zoom image either in the same place.. which is what I am trying to do or in another div beside. I have had to set me img srcs up in a certain way to easily enter some product details. and I need to try an manipulate the code to make it work to suit my file layout. I am using a var= images [ with a series of file locations and info such as below { src: 'romanticabride/thumbs/tn_Shauna.jpg', srcBig: 'romanticabride/images/Shauna.jpg', title: 'Shauna', longDescription: '<b><H1>Shauna</H1></b><br><b>Romantica Of Devon <br><br><h2>Sizes Available:</h2><br> 6 - 32.<b><br><b><br><b><b><b><H2>Colours Available:</h2><b><br>Various<br>Please Enquire Below<br><br><br><br><a href="mailto:tracy@cherishbridal.co.uk?subject=Web Enquiry Regarding Romantica Shauna Bridal Gown"class="enquiry rose glow" >Click To Enquire About This Item </a>' }, what I need is for cloud zoom to work when the main image wrapper is hovered over which means it will need to add a class or when the whichever srcBig: is hovered over it gets wrapped by href to make the script work . one of my pages is http://www.cherishbridal.co.uk/romaticabride.html the cloud zoom script is at http://www.professorcloud.com/mainsite/cloud-zoom.htm.. I am happy to share a jsfiddle with someone or explain further or post some code. Thank you in advance does any expert know how to pass parameters in the <script ..> tag? for instance; Code: <script type="text/javascript" src="script.js ?param1=val1¶m2=val2&etc "> in the javascript script.js, how would we read the params after the question mark? for example, google this; google shopping cart /v2_2/cart.js I have a script that works in seamonkey(my html editor) but when I use it in IE8 it says errors happen. Here's the code (the first line is on line 7 of the html file): Code: <script type="text/javascript"> function enlarge(imageNum) { var numToString = ""; if(parseInt(imageNum) < 10){ numToString = "0" + imageNum; } else { numToString = imageNum + ""; } window.open("images/LgScreenshot"+numToString+".jpg","Screenshot "+imageNum,"status=0,height=675,width=900,resizable=0"); } </script> And the errors: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB0.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.3; .NET CLR 3.0.30729) Timestamp: Wed, 10 Feb 2010 14:58:16 UTC Message: Object expected Line: 150 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html Message: Invalid argument. Line: 18 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html I need to assign a key in the javascript to actually make the javascript work,. I have a bookmark in chrome , a javascript , which actually works when clicked on it .,. but how can i edit it so that i can actually make it work on click a key or combination of keys. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. Thanks in advance ., Nani On this website: http://evancoleman.net/index.php I really like on the top how the menu has like 5 or 6 icons, and when you hover over them it shows a bubble with the name in them. Does anybody know where I can find this script? Thanks. Hello again . If these questions concerning Regular Expressions are inappropriate in this forum please let me know . Thank You. This expression <script[^>]*>.*?</script> matches ... Code: <script type="text/javascript">var cnnIsHomePage = true;</script> but not ... Code: <script type="text/javascript"> var cnnIsHomePage = true; </script> Please , how can i match the latter ? Hi: Code below works fine in Firefox and Firebug shows no problems. Code: function changePlaylist(newplaylist,no_of_items) { playerConfig.playlist = []; for(var i = 0; i < no_of_items; i++) { playerConfig.playlist[i] = newplaylist; } setTimeout("createPlayer()",1); //delay create player to allow playlist to "stabilize" mediaPlayer.play(); // play the newly loaded playlist sequence* } IE9 script debugging (attached file) indicates problems with mediaplayer.play(). Even so it plays a movie. When I try playing a different movie in IE 9 nothing happens. Like I said works fine in Firefox and worked fine in IE 8. I called MS about problems with IE 9 security stuff etc. Talked with a guy in Bangladesh or some place over a bad connection who said they were gathering bug information (as usual with MS). All the dialogs where you can "allow scripting" etc. etc. have been replaced with some mindless stuff (as usual for MS). Anyway, are there some workarounds for IE9 problems? hi am studying for a exam an i have some problems. Just wanted to get an idea when is it more appropriate to use a for than a while loop? how much work is a loop performing? what is the fewest times a loop will perform its body? how many times will a loop perform its body? (as a function of a constant and of a variable) i have 3 different problems: 1. I was trying to make is display Kentucky Resident yes is the box is checked and nothing if it is not checked. 2. while trying to add this in I messed something up and not the alert will not display anything at all. 3. last time I click the button the play load a page error and i have no idea why. any and all help would be appreciated. thanks. Code: <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>EKU</title> <script type="text/javascript"> //<![CDATA[ function valStudent() { var lastName = document.frmStudentInfo.txtLastName.value; var firstname = document.frmStudentInfo.txtFirstName.value; var mi = document.frmStudentInfo.txtS_Mi.value; var address = document.frmStudentInfo.txtS_Add.value; var city = document.frmStudentInfo.txtS_City.value; var state = document.frmStudentInfo.txtS_State.value; var zip = document.frmStudentInfo.txtS_Zip.value; var phone = document.frmStudentInfo.txtS_Phone.value; var dob = new Date (document.frmStudentInfo.txtS_Dob.value); var selectAdvisor = document.frmStudentInfo.lstF_ID.selectIndex; var res = document.frmStudentInfo.chkResident.value; var stuClass; var classChecked = false; for (var i=0; i < document.frmStudentInfo.optS_Class.length; i++) { if (document.frmStudentInfo.optS_Class[i].checked) { classChecked = true; stuClass = document.frmStudentInfo.optS_Class[i].value; } } if (lastName == "") { alert ("Please enter a last name"); document.frmStudentInfo.txtLastName.select(); return false; } else if (firstname == "") { alert ("Please enter a first name"); document.frmStudentInfo.txtFirstName.select(); return false; }else if (address == "") { alert ("Please enter a address"); document.frmStudentInfo.txtS_Add.select(); return false; } else if (city == "") { alert ("Please enter a city"); document.frmStudentInfo.txtS_City.select(); return false; } else if (state == "") { alert ("Please enter a state"); document.frmStudentInfo.txtS_State.select(); return false; } else if (zip == "") { alert ("Please enter a zip"); document.frmStudentInfo.txtS_Zip.select(); return false; } else if (phone == "") { alert ("Please enter a phone"); document.frmStudentInfo.txtS_Phone.select(); return false; }else if (dob == "NaN") { alert ("Date of Birth is not valid, use MM/DD/YYYY to enter data"); document.frmStudentInfo.txtS_Dob.select(); return false; }else { alert ("Last name: " + lastName + "\n" + "First Name: " + firstname + "\n" + "mi: " + mi + "\n" + "Address: " + address + "\n" + "City: " + city + "\n" + "State: " + state + "\n" + "Zip: " + zip + "\n" + "phone: " + phone + "\n" + "Date of Birth: " + dob + "\n" + "Advisor " + document.frmStudentInfo.lstF_ID.text(selectAdvisor).text + "\n" + "classfication " + stuClass); return true; } } //]]> </script> </head> <body> <table width="70%" align="center"> <tr> <td><img src="nwlogo.jpg" width="196" height="93" alt="** PLEASE DESCRIBE THIS IMAGE **" /></td> <td> <h2>Student Information</h2> </td> </tr> </table> <form name="frmStudentInfo" action="action%20marker" id="frmStudentInfo"> <table align="center"> <tr> <td> Last Name:</td> <td><input type="text" name="txtLastName" size="20" /></td> <td></td> <td> </td> <td> <h4>Class:</h4> </td> <td></td> </tr> <tr> <td> First Name:</td> <td><input type="text" name="txtFirstName" size="20" /></td> <td> </td> <td><input type="radio" name="optS_Class" value="Freshman" /></td> <td>Freshman</td> </tr> <tr> <td> MI:</td> <td><input type="text" name="txtS_Mi" size="5" /></td> <td> </td> <td><input type="radio" name="optS_Class" value="Sophomore" /></td> <td>Sophomore</td> </tr> <tr> <td> Address:</td> <td><input type="text" name="txtS_Add" size="20" /></td> <td> </td> <td><input type="radio" name="optS_Class" value="Junior" /></td> <td>Junior</td> </tr> <tr> <td> City:</td> <td><input type="text" name="txtS_City" size="20" /></td> <td> </td> <td><input type="radio" name="optS_Class" value="Senior" /></td> <td>Senior</td> </tr> <tr> <td> State:</td> <td><input type="text" name="txtS_State" size="5" /></td> <td> </td> <td><input type="radio" name="optS_Class" value="Graduate" /></td> <td>Graduate</td> </tr> <tr> <td> ZIP Code:</td> <td><input type="text" name="txtS_Zip" size="20" /></td> <td> </td> <td></td> <td></td> </tr> <tr> <td> Phone:</td> <td><input type="text" name="txtS_Phone" size="20" /></td> <td> </td> <td>:<input name="chkResident" type="checkbox" /></td> <td> Kentucky Resident</td> </tr> <tr> <td> Date of Birth:</td> <td><input type="text" name="txtS_Dob" size="20" /></td> <td> </td> <td>Advisor</td> <td><select size="1" name="lstF_ID"> <option selected="selected">1 (Chuck Lin)</option> <option>2 (Chris Blades)</option> <option>3 (Steve Loy)</option> <option>4 (Bob Mahaney)</option> <option>5 (Ted Randles)</option> </select></td> </tr> <tr> <td></td> <td><input type="submit" value="Submit" onclick="valStudent()" /></td> </tr> </table> </form> </body> </html> insidehb.com/main/imageofday/aug16to31/aug16to31.htm 1. the "visit henrbuilt" link is in the wrong position (its supposed to be centered) 2. there are too many thumbnails for "aug 16 - 31" so i had to redo "thumbs_mask.gif" (which makes the gray and clear thing at the bottom that moves) so that it was longer and covered all the thumbnails. now that is is 400 px longer, the center of it moved 200px to the right and i cant get it to move 200px to the left. i would i guess it has to do with my style sheet (insidehb.com/main/imageofday/aug16to31/style13.css) but it could also have to do with my main html page (insidehb.com/main/imageofday/aug16to31/aug16to31.htm) 3. its still being messed up in IE even with a new doctype I am putting together a quiz in the form of a game, and I have tested the code for problems, and found a big one. Here is a part of my code that doesn't work- it always goes to "Sorry, incorrect", even when I type in 2.37. Code: var x=document.getElementById("varsource1"); if (x==="2.37") { alert("Correct."); (More code here) } else if(x !== "2.37") { alert("Sorry, incorrect."); } If anyone wants my whole code, I can put it up later, if you ask me for it. 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> Hi, I have a sign-up/login form, the address is http://www.my-walk.com/signup_login.php I have arranged the elements in a table, and left the 3rd column in each table blank. When the form is submited, i want the code to display any errors with the code in these colums. E.g. If username is already used, display "Username already taken" in the 3rd colum of the username input row. Code is: [CODE] <script style="text/javascript" language="javascript"> var login = document.getElementById("login_form_table"); var signup = document.getElementById("signup_form_table"); <?php if (isset($_POST['submit_login'])) { $username = secure($_POST["username"]); $password = secure($_POST["password"]); $r = mysql_query ("SELECT * FROM members WHERE username = '".$username."'"); $num = mysql_num_rows($r); if($num == 0) { ?> alert("username not found"); login.rows[1].cells[3].innerHTML = "Username not found."; <?php } else { $row = mysql_fetch_assoc($r); if (($row["username"]==$username && ($row["password"]==$password))) { session_start(); session_register('id'); session_register('username'); $_SESSION['id'] = $row['id']; $_SESSION['username'] = $row['username']; header("Location: index.php"); } else { echo ('Username and Password do not match. Please try again </br>'); } } } if (isset($_POST['submit_signup'])) { $email = secure($_POST["email"]); $username = secure($_POST["username"]); $password = secure($_POST["password"]); $confirmpassword = secure($_POST["confirmpassword"]); $optin = secure($_POST["optin"]); if($optin=="checked") { $optin = 1; } else { $optin = 0; } $r = mysql_query ("SELECT * FROM members WHERE email = '".$email."'"); $num = mysql_num_rows($r); if(!$num == 0) { ?> alert("Email already"); signup.rows[0].cells[2].innerHTML = "A user has already signed up with this Email address."; <?php } elseif(!eregi($pattern, $email)) { ?> alert("non valid email"); signup.rows[1].cells[2].innerHTML = "Not a valid Email address!"; <?php } elseif($password != $confirmpassword) { ?> alert("password mismatch"); signup.rows[2].cells[2].innerHTML = "Passwords do not match."; signup.rows[3].cells[2].innerHTML = "Passwords do not match."; <?php } elseif(strlen($username) < 7) { ?> alert("more characters"); signup.rows[1].cells[2].innerHTML = "Username must be at least 6 letters."; <?php } elseif(strlen($password) < 7) { ?> alert("less characters"); signup.rows[2].cells[2].innerHTML = "Password mustbe at least 6 letters."; <?php } else { $r = mysql_query ("INSERT INTO members (username, email, password, optin, date) VALUES ('".$username."', '".$email."', '".$password."', '".$optin."', curdate())"); $r = mysql_query ("SELECT * FROM members WHERE email = '".$email."'"); $row = mysql_fetch_assoc($r); if($r) { session_start(); session_register('id'); session_register('username'); $_SESSION['id'] = $row['id']; $_SESSION['username'] = $row['username']; header("Location: index.php"); } else { echo 'An error occured, please attempt to sign-up again </br>'; } } } ?> </script> [CODE] as you can see there is 2 forms, and the issues a 1. None of the innerhtml parts are working. 2. I want all errors to be shown once submited, so far only 1 is dispalying at a time. I thought elseif meant it would trigger all the problems? Thanks for your help, Rick I have two problems with this simple survey that I am trying to write: 1. When I have the "<textarea>" code lines in it put a text-area on the page, but it puts all of the code following that first text-area line into the text-area box and doesn't execute that segment of code. 2. When there is no "<textarea>" (for the sake of seeing if the rest of it worked) it doesn't check the survey. I'm stumped and can't figure out what to do at this point, can someone please help me with this? Code and pictures follow: Code: <html> <head> <title>Survey</title> <script langauge-"javascript"> <!-- var food=new Array("Berries", "Carrots", "Insects", "Salmon", "Salad", "Smelt", "Trout"); var story=new Array("Peter Rabbit", "Molly's Adventure", "Jeremy Fisher", "Mrs. TiggieWinkle", "The Tale of the Two Bad Mice", "Toad's Great Adventure"); function createWindow() { win=open("", "", "menubar, scrollbars"); win.document.write("<head><title>Survey Results</title></head>"); win.document.write("<body bgcolor='white'>"); return win; } function checkSurvey(form) { var outString=""; for(var i=0; i<=2; i++) { if(form.elements[i].value=="") { alert("Please fill in your "+form.elements[i].name); form.elements[i].focus(); return; } outString=outString+form.elements[i].name+":"+form.elements[i].value; outString+="<br>"; } if(!form.Attending[0].checked&&!form.Attending[1].checked) { alert("Please fill in the attendence information"); return; } if(form.Attending[0].checked) { outString+="Attending: Yes<br>"; var index=form.Food.selectedIndex; outString=outString+"Favorite Food: "+food[index]+"<br>"; index=form.Story.selectedIndex; outString=outString+"favorite Story: "+story[index] + "<p>"; } else outString += "Attending: No <p>"; win.document.write(outString); } //--> </script> </head> <body bgcolor="white" onLoad = "win = createWindow()" onUnload = "win.close()"> <b>The Survey</b><p> <i>Please help us by filling our this survey</i><p> <table cellpadding = "3"> <form name = "Survey"> <tr><td>First Name</td> <td colspan = "3"> <input type = "text" name = "First Name" size = "12"></td></tr> <tr><td>Last Name</td> <td colspan = "3"> <input type = "text" name = "Last Name" size = "3"></td></tr> <tr><td>Address</td> <td colspan = "3"> <textarea name = "Address" rows = "5" cols = "30" wrap = "physical"> </teaxtarea></td></tr> <tr><td>Attending?</td> <td><input type = "radio" name = "Attending" value = "Yes">Yes</td> <td><input type = "radio" name = "Attending" value = "No">No</td></tr> <tr><td>Favorite Foods</td> <td colspan="3"><select name = "Food"> <script langauge = "javascript"> <!-- for(var i=0; i<food.length; i++) document.write("<option>" + food[i]); //--> </script></select></td> </tr> <tr><td>Favorite Story</td> <td colspan = "3"><select name = "Story"> <script language="javascript"> <!-- for(var i=0; i<story.length; i++) document.write("<option>" + story[i]); //--> </script></select></td></tr> <tr><td><input type = 'button' value = 'Check Survey' onClick = "checkSurvey(this.form)"></td></tr></form> </table> </body> </html> Any help would be greatly appreciated! I'm using javascript to create a slideshow of images with thumbnails. The slideshow works fine, the titles show up great, but my problem arises when I try to replace the href source of a div. [larger], specified in the js is supposed to be replacing the current a href source, but it isn't working. This is the javascript that controls the slideshow: Code: var current = 0; function swapimg( show ){ var piece = new Array(); var title = new Array(); var larger = new Array(); var meta = new Array(); piece[0] = '../assets/images/nokia/nokia01.jpg'; title[0] = '[ One ]'; larger[0] = '../assets/images/nokia/nokia01_big.jpg'; piece[1] = '../images/nokia/nokia02.png'; title[1] = '[ Two ]'; larger[1] = '../assets/images/nokia/nokia02_big.jpg'; piece[2] = '../assets/images/nokia/nokia03.png'; title[2] = '[ Three ]'; larger[2] = '../assets/images/nokia/nokia02_big.jpg'; piece[3] = '../assets/images/nokia/nokia04.png'; title[3] = '[ Four ]'; larger[3] = '../assets/images/nokia/nokia02_big.jpg'; document.getElementById( 'featured' ).src = piece[show]; document.getElementById( 'featured' ).alt = title[show]; document.getElementById( 'featuretitle' ).innerHTML = title[show]; document.getElementById( 'featuremeta' ).innerHTML = meta[show]; document.getElementById( 'featurelarger' ).href = larger[show]; for( i = 0; i < meta.length; i++ ){ document.getElementById( 'item' + i ).style.opacity = '.5'; } document.getElementById( 'item' + ( show ) ).style.opacity = '.99'; current = ( show ); } And this is the portion of the html that is supposed to be working with the [larger], but I'm having troubles with: Code: <div class="featurelarger"><a href="../assets/images/nokia/nokia01_big.jpg" id="featurelarger" class="thickbox" title="Windowcling" rel="gallery-art" >view larger</a></div> Any help would be greatly appreciated, thank you in advance! Hi there, I'm hoping someone can help me... I am using Galleria (http://galleria.aino.se/) for a friend's website but I just can't get it to work... I haven't used JavaScript or JQuery much and it's driving me mad!! I've followed all the instructions on the site, and lots of examples I have found all over the web... This one was most successful - http://monc.se/kitchen/stew/galleria/ the furthest I have been able to get is thumbnails showing, but when you click on them you can't see the gallery - see he http://lisacritcher.skillsontoast.co.uk/?page_id=28 I know the formatting is all off but I'm not worried about that for now... I just want to get the gallery working!! Can anyone help? Thanks in advance |