JavaScript - Cannot Get The Equlcolumns.js To Produce Equal Column Height.
This is the program.and here is the script.
I have tried all I know without success. This Sources program is on another css/html forum for another issue. Frank Code: //** Dynamic Drive Equal Columns Height script v1.01 (Nov 2nd, 06) //** http://www.dynamicdrive.com/style/blog/entry/css-equal-columns-height-script/ var ddequalcolumns=new Object() //Input IDs (id attr) of columns to equalize. Script will check if each corresponding column actually exists: ddequalcolumns.columnswatch=["Content1", "content2", "content3",] ddequalcolumns.setHeights=function(reset){ var tallest=0 var resetit=(typeof reset=="string")? true : false for (var i=0; i<this.columnswatch.length; i++){ if (document.getElementById(this.columnswatch[i])!=null){ if (resetit) document.getElementById(this.columnswatch[i]).style.height="auto" if (document.getElementById(this.columnswatch[i]).offsetHeight>tallest) tallest=document.getElementById(this.columnswatch[i]).offsetHeight } } if (tallest>0){ for (var i=0; i<this.columnswatch.length; i++){ if (document.getElementById(this.columnswatch[i])!=null) document.getElementById(this.columnswatch[i]).style.height=tallest+"px" } } } ddequalcolumns.resetHeights=function(){ this.setHeights("reset") } ddequalcolumns.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload) var tasktype=(window.addEventListener)? tasktype : "on"+tasktype if (target.addEventListener) target.addEventListener(tasktype, functionref, false) else if (target.attachEvent) target.attachEvent(tasktype, functionref) } ddequalcolumns.dotask(window, function(){ddequalcolumns.setHeights()}, "load") ddequalcolumns.dotask(window, function(){if (typeof ddequalcolumns.timer!="undefined") clearTimeout(ddequalcolumns.timer); ddequalcolumns.timer=setTimeout("ddequalcolumns.resetHeights()", 200)}, "resize") Similar TutorialsHi all.. I've been trying to get random numbers in JS. It works when I assign fixed values, but when I want those values to come from a form, I get all the problems.. any comments on my script? Thanks. M [CODE] <script type="text/javascript"> function random() { var x=document.getElementById("text1").value;// num ingresado por el usuario var y=document.getElementById("text2").value; //var x=1; //var y=6; num=Math.floor(x + Math.random() * y); var r=document.getElementById("demo") r.innerHTML=num; } </script> [CODE] I have no js experience or coding experience of any kind other than the last few hours of reading a book called 'object-oriented javascript', and all was well until loops. firstly, this is how he teaches the while loop... var i = 0; while (i <10) {i++;} which results in 9 we move on to for loops... var res =''; for( var i = 0; i <10; i++) {res += 'sometext' ;} which repeats, but I'd like to be able to make that into a sequence of numbers... 123456789. how do I do that? thanks. Hi, I'd like to set the div width equal to the image width. Here's what I can think of: Code: <script type="text/javascript"> window.onload = function () { document.getElementById('foo').style.width = document.getElementById('bar').width + 'px'; } </script> <div id="foo" style="background:red;"><img id="bar" src="image.jpg"></div> It seems to be working, but I'm not sure if it's correct coding. Thanks in advance for checking the code or any improvement you suggest! Rain lover Could anyone tell me (or link me to some place that can) why the following if-statement will execute? if (5!=6 || 7!=8) { alert("Why does this work?"); } Thanks Hi all, I'll get it out their early, I am somewhat of a javascript novice. Here is the code I am working with: Code: <script type="application/javascript"> $(document).ready(function() { var numitems = $("#foo6 > li").length; var secondstartpoint = numitems -3; }); </script> <script type="text/javascript" language="javascript"> $(function() { $("#foo6").carouFredSel({ width : 136, height: 822, scroll : { items:1 }, items : { visible: 6, start: secondstartpoint }, easing:"swing", auto : false, prev : "#next3", next : "#prev4", direction:"down", align:"left" }); }); </script> As you can probably see I am trying to set the start point of a jquery carousel to equal a variable that I have created. You can see I have tried " start: secondstartpoint", but this isn't working. I think possibly because the way the plugin is formatted so that the "start" option can only equal a number. Can anyone shed some light on this issue and perhaps even suggest a solution? Thanks in advance guys Dan I'm looking for a simple javascript that can fill in the subject of an email message with whatever is in the title tags of the page they're on and also to include the link the the page in the body. [CODE] <a href="mailto:e@o.com?subject=&body=http://www.o.htm" title="Question"> [CODE] Thanks! How would I clean up this code? it looks so ugly, would I put it in a for loop and make it loop through and set the rand2, rand3, rand4 = place... there so there is a lot less lines of code(which is what I want) I need a cleaner way to do this, so it isn't so much space. Can someone help? there needs to be different variables because I need the random to be different for each, so rand2 = different random value than rand3. var place = [74,111,148,185,222,259,296,333,370]; var random = [rand,rand2,rand3,rand4,rand5,rand6,rand7,rand8,rand9]; var rand = place[Math.floor(Math.random()*place.length)]; var rand2 = place[Math.floor(Math.random()*place.length)]; var rand3 = place[Math.floor(Math.random()*place.length)]; var rand4 = place[Math.floor(Math.random()*place.length)]; var rand5 = place[Math.floor(Math.random()*place.length)]; var rand6 = place[Math.floor(Math.random()*place.length)]; var rand7 = place[Math.floor(Math.random()*place.length)]; var rand8 = place[Math.floor(Math.random()*place.length)]; var rand9 = place[Math.floor(Math.random()*place.length)]; var newrand = place[Math.floor(Math.random()*place.length)]; var newrand1 = place[Math.floor(Math.random()*place.length)]; var newrand2 = place[Math.floor(Math.random()*place.length)]; var newrand3 = place[Math.floor(Math.random()*place.length)]; var newrand4 = place[Math.floor(Math.random()*place.length)]; var newrand5 = place[Math.floor(Math.random()*place.length)]; var newrand6 = place[Math.floor(Math.random()*place.length)]; var newrand7 = place[Math.floor(Math.random()*place.length)]; var newrand8 = place[Math.floor(Math.random()*place.length)]; var newrand9 = place[Math.floor(Math.random()*place.length)]; var old = place[Math.floor(Math.random()*place.length)]; var old1 = place[Math.floor(Math.random()*place.length)]; var old2 = place[Math.floor(Math.random()*place.length)]; var old3 = place[Math.floor(Math.random()*place.length)]; var old4 = place[Math.floor(Math.random()*place.length)]; var old5 = place[Math.floor(Math.random()*place.length)]; var old6 = place[Math.floor(Math.random()*place.length)]; var old7 = place[Math.floor(Math.random()*place.length)]; var old8 = place[Math.floor(Math.random()*place.length)]; var old9 = place[Math.floor(Math.random()*place.length)]; Hi, I need to re-size a div to be 100% of the browser but taking into account the height of an existing header div. Currently it works but it doesn't factor the height of the above header div, and therefore scrolls off the page (the height of the header div) I need to manipulate ( subtract the height value of the header) in the javascript somehow. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript"> function SetHeightOfDiv(){ var theDiv = document.getElementById('content'); theDiv.style.height = BrowserHeight()+"px"; } function BrowserHeight() { var theHeight; if (window.innerHeight) { theHeight = window.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { theHeight = document.documentElement.clientHeight; } else if (document.body) { theHeight = document.body.clientHeight; } return theHeight; } </script> </head> <body style="height:100%; background-color:blue; margin:0; padding:0; color:#ffffff; font-size:15px; text-align:center; font-family:monospace,arial" onload="SetHeightOfDiv()"> <div id="wrapper" style="height:100%; width:900px; background-color:yellow; margin-left:auto; margin-right:auto; overflow:hidden"> <div id="header" style="margin-top:0px; height:130px; width:890px; margin-left:5px; background-color:red; position:fixed"> <p>The FIXED HEADER</p> </div> <div id="content" style="margin-top:132px; background-color:grey; width:890px; margin-left:5px"> <p>THE BODY - that extends below the browser window (possibly the height of the header)</p></br> <p>So how do we manipulate the Javascript to 'Subtract' the height of the HEADER?</p></br> <p style="text-align:left; padding-left:10px"> function SetHeightOfDiv(){ <br> var theDiv = document.getElementById('content');<br> theDiv.style.height = BrowserHeight()+"px";<br> }<br> </br> function BrowserHeight() {<br> var theHeight;<br> if (window.innerHeight) {<br> theHeight = window.innerHeight;<br> }<br> else if (document.documentElement && document.documentElement.clientHeight) {<br> theHeight = document.documentElement.clientHeight;<br> }<br> else if (document.body) {<br> theHeight = document.body.clientHeight;<br> }<br> return theHeight;<br> }</p> </div> </div> <!--end of wrapper--> </body> </html> Thanks Hello, let me try to explain better what I'm trying to do. I'm a real newbie I don't know much javascript but I understand more or less the logic behind it... tell me if this solution should work and if you know how to do it please show me. I have this page. http://felixdeportu.com/5/ The images are inside a div#content div#photo. I need to make div#photo's width to match the total width measurement of all the images it contains. If you load the page and you don't touch the size, it will work fine... but that's not realistic. If I resize the page, which will happen often on this kind of page (I'm assuming), the whole thing goes haywire (try it, scroll to the last image and resize the page you'll see what I mean). What can I do? Is my idea the right solution? Am I not explaining this clearly enough? Let me know please, I'm desperate. I've been trying to get CSS to do this for me for 3 hours now. Nothing works... Thank you for your help with this. I am newer to JS and appreciate the assistance. I am using iScroll for an image gallery on the iPad. I can place 120 columns equalling 122,880 pixels in width. After that the content fails to display. How can I get additional 180 columns that I have to display? Hi all! I am trying to implement the "Freeze pane" feature in javascript as it is in excel. I am almost there but am not able to get one last thing. The row header freezing is achieved first column freezing is also achieved. However, the top left column cell (which is supposed to stay frozed during both horizontal and vertical scroll) is not frozen. Prompt help is highly appreciated! Please find the html file and the js file being used. Thanks a bunch! Ree Hi I'm really new to this and don't really know if I'm in the right place as for posting. I'm trying to figure out if there is a way to have like a news column on each html page that can be updated by making changes to one file. Kinda like a embedded window that gives a sample of some of the text on the highlights page and then has a click to read more. I was thinking a javascript app would be best but I new at this and don't really understand everything. If someone has an idea or can help it'd be appreciated
Hi, I'm trying to change the column from javascript using. cell.width='7'; or cell.style.width="7px"; when i set this. all the columns in each row within the table are resetting to this column width. How can i make sure that this reflects for only one row for which i set this property to. Please let me know. I am attempting to sync the column widths of two tables. Currently, I have a working method that uses the DOM to traverse each cell of a given row of two tables and set the style.width element to the largest offsetWidth of the the two cells. However, when the divs my tables are in are given an overflow: auto property, causing scrollbars, the widths no longer sync. They style.width elements are still being set (I'm using a debugging method to check the style.width elements for their values), but no sizes are changing. Ideas? ASPX Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <%@language = "C#" inherits="APTEIT.Default"%> <!-- Default.aspx Author: Steven T. Norris Created: 2/28/2012 Last Updated: Updated By: Default page of APTEIT --> <link rel="stylesheet" type="text/css" href="CSS/APTEIT.css"/> <script type="text/javascript" src="Utilities/Javascript/Utilities.js"></script> <script type="text/javascript" src="Utilities/Javascript/jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ HtmlLoggerControlInstance.getInstance().setLevel("debug",HtmlLogger.ALL); syncColumnWidths("headers",null,"data",null); }); </script> <html> <head> <title>APTEIT</title> </head> <body> <!--#include file="Utilities/Debug.aspx"--> <img src="Images/logo.png" /> <div id="headersDiv"> <table class="tbl" id="headers"> <tr> <td>head1</td> <td>head2reallyreallylong</td> <td>hd3</td> <td>4</td> </tr> </table> </div> <div id="dataDiv" onscroll="syncScrolling('dataDiv','headersDiv');"> <table class="tbl" id="data"> <tr> <td>alsdja;lksdjaljkdf</td> <td>kdki</td> <td>k39</td> <td>lsjdl</td> </tr> <tr> <td>alsdja;lksdjaljkdf</td> <td>kdki</td> <td>k39</td> <td>lsjdl</td> </tr><tr> <td>alsdja;lksdjaljkdasdfaf</td> <td>kdki</td> <td>k39</td> <td>lsjdl</td> </tr><tr> <td>alsdja;lksdjaljkdf</td> <td>kdki</td> <td>k39</td> <td>lsjdl</td> </tr><tr> <td>alsdja;lksdjaljkdfs</td> <td>kdki</td> <td>k39</td> <td>lsjdl</td> </tr><tr> <td>alsdf</td> <td>kdki</td> <td>k39</td> <td>lsjdl</td> </tr> </table> </div> </body> </html> CSS Code: /* APTEIT.css Author: Steven T. Norris Created: 2/28/2012 Updated By: Last Updated: Copyright 2012 CSS stylesheet for default page of APTEIT */ /*Utilities Styles*/ .debug { display:block; } .LOG_INFO { color:blue; } .tbl { border-collapse:collapse; } .tbl tr td { border-width:1px; border-color:black; border-style:solid; } #headersDiv { max-width:200px; overflow:hidden; } #dataDiv { max-width:200px; overflow:auto; } #headers { table-layout:fixed; } #data { table-layout:fixed; } Javascript Code: /* Utilities.js Author: Steven T. Norris Created: 3/2/2012 Updated By: Last Updated: Copyright 2012 Utility functions Logs to debug window if using Debug.aspx or a logger named 'debug' with the HtmlLoggerControlInstance */ /* Syncs column sizes between two tables. @param string table1 : First table to sync @param int table1HeadRow : Row to use as column width sync for table1 (if null, uses first row) @param string table2 : Second table to sync @param int table2HeadRow : Row to use as column width sync for table2 (if null, uses first row) */ function syncColumnWidths(table1, table1HeadRow ,table2, table2HeadRow){ UtilLogger.log(HtmlLogger.INFO,"-Syncing Column Widths-") if((typeof table1 == "string" ||table1.constructor == String) && (typeof table2 == "string" ||table2.constructor == String) && (typeof table1HeadRow == "number" || table1HeadRow == null) && (typeof table2HeadRow == "number" || table1HeadRow == null)){ tableOne = document.getElementById(table1); tableTwo = document.getElementById(table2); //Set row to check and get row if(table1HeadRow == null){ t1Start = 0; } else{ t1Start = table1HeadRow; } if(table2HeadRow == null){ t2Start = 0; } else{ t2Start = table2HeadRow; } t1Row = tableOne.rows[t1Start]; t2Row = tableTwo.rows[t2Start]; //Get end number if(t1Row.cells.length < t2Row.cells.length){ tEnd = t1Row.cells.length; } else{ tEnd = t2Row.cells.length; } //Sync widths for(i = 0; i < tEnd; i++){ UtilLogger.log(HtmlLogger.CONFIG,"syncColumnWidths:t1 width:"+t1Row.cells[i].offsetWidth+" t2 width:"+t2Row.cells[i].offsetWidth); if(t1Row.cells[i].offsetWidth > t2Row.cells[i].offsetWidth){ t2Row.cells[i].style.width = t1Row.cells[i].offsetWidth+"px"; t1Row.cells[i].style.width = t1Row.cells[i].offsetWidth+"px"; UtilLogger.log(HtmlLogger.FINE,"syncColumnWidths:setting t2 width to t1"); UtilLogger.log(HtmlLogger.FINER,"syncColumnwidths:t1 style width:"+t1Row.cells[i].style.width+" t2 style width:"+t2Row.cells[i].style.width); } else{ t1Row.cells[i].style.width = t2Row.cells[i].offsetWidth+"px"; t2Row.cells[i].style.width = t2Row.cells[i].offsetWidth+"px"; UtilLogger.log(HtmlLogger.FINE,"syncColumnWidths:setting t1 width to t2"); UtilLogger.log(HtmlLogger.FINER,"syncColumnwidths:t1 style width:"+t1Row.cells[i].style.width+" t2 style width:"+t2Row.cells[i].style.width); } } } else{ alert("syncColumnWidths takes parameters (string, int|null, string, int|null)"); } UtilLogger.log(HtmlLogger.INFO,"-Syncing Column Widths Complete-"); } /* Syncs scrolling of two divs. Meant to be part of onscroll event for primary div @param string div1 : primary div. normally the div who's onclick event houses this method @param string div2 : secondary div */ function syncScrolling(div1,div2){ if((typeof div1 == "string" || div1.constructor == String) && (typeof div2 == "string" || div2.cosntructor == String)){ $("#"+div2).scrollLeft($("#"+div1).scrollLeft()); } else{ alert("syncScrolling takes parameters (string, string)"); } } using a javascript function to determine if a string is all digits or not and return result based off the decision. if it is all digits, mask all digits except the first two, if not all digits just return the string. these are the snippets however i am not seeing anything returned in the column Code: <script > var start = function RenderRC(CodeOwner) { var Rcode = CodeOwner.toString(); var pattern = new RegExp("^\d{2,}$ "); if (Rcode.match(pattern)) { if (Rcode.length > 2) { var newcode = Rcode.substr(0, 2) + Array(Rcode.length - 2 + 1).join("*"); return newcode; } } else { return Rcode; } }; </script> <ext:RecordField Name="CodeOwner" /> <ext:Column Header="<%$ Resources:Text, CodeOwner %>"DataIndex="CodeOwner" Width="110" > <Renderer Fn ="start" /> </ext:Column> have a div & a grid i want the div to be displayed on the column header click & be positioned with the specific column suppose 3rd grid header column is clicked the div shld be positioned near 3 column Hello, I need your help. I'd like to be able to populate a combo box (drop down box) from a column in my mdb database: Ex. of whats in mdb database Name -------------- Joey Jacob Smith Jerrod Patrick What should appear in drop down: [ ==== COMBO BOX ==== ] Joey Jacob Smith Jerrod Patrick I cant seem to find any help on the web for this? Thanks for all your help in advance. Hi I read a lot of data from excel sheets into JS arrays. I have a situation where i have name, hours, product id and other few entries. I have all these details as array in array concept. eg. array.push(new Array(name,hours,pid,price,place)) Redundant entries that include same names,pid, places will be found in the array. My prob is to sum up all the hours of the records that belong to same name and product id and store the unique records in one array and ofcourse the hours column sumed up. name pid hours place ---------------------- aaaa 11 100 chennai aaaa 11 200 chennai cccc 22 30 coimbatore dddd 33 45 chennai dddd 22 100 chennai dddd 33 200 chennai my output should be name pid hours place --------------------- aaaa 11 300 chennai cccc 22 30 coimbatore dddd 33 245 chennai dddd 22 100 chennai can anyone help?? I cannot figure out how to total my column data correctly with JavaScript. The code I have will enter a new row, but it is not summing the columns. The new row is just filled with zeros. Code: function totalColumns() { var tds = document.getElementById('users_table').getElementsByTagName('td'); var sum = 0; for(var i = 0; i < tds.length; i ++) { if(tds[i].className == 'dataRow') { sum += isNaN(tds[i].innerHTML) ? 0 : parseInt(tds[i].innerHTML); } } document.getElementById('users_table').innerHTML += '<tr><td>' + sum + '</td><td>' +sum+ '</td><td>' +sum + '</td></tr>'; alert ("Columns have been totalled and listed at the bottom of each"); } //end totalColumns I can't figure out how to get the rows to total at all. Any insight would be appreciated! Thanks! |