HTML - Problem With Dynamic Scroll, Adding And Deleting From Table
Hello,
I have a table (with one cell). The table can be quite big (200 items) so I would like the user to be able to scroll it up and down... and I want the user to be able to add and delete an item. I have done something with javascript but it is not complete.. the delete does not work correctly ... the scroll up and down shown the same table. I don't have a clue on how to do the add button. Could you help me please? Here is what I have done so far.... Code: <html> <head> <title>Insert/Delete Table Row using DOM</title> <link rel="stylesheet" type="text/css" href="style.css"> <style type="text/ccs"> <!-- form {border:1px solid blue;} div {border:1px solid red; width:150px; overflow:auto;} .selectBox { font-size:xx-small;overflow:auto;} #tblSample td,th {padding:0.5em;} .classy0 { background-color: #234567; color:#89abcd;} .classy1 {background-color: #89abcd; color:@234567;} --> </style> <%@ include file="javascriptLib.html" %> <script language="JavaScript" type="text/JavaScript"> <!--- oculta el script para navegadores antiguos var INPUT_NAME_PREFIX = 'inputName'; // this is being set via script var TABLE_NAME = 'items_list'; // this should be named in the HTML var LABEL_NAME = 'label_list'; var ROW_BASE = 1; // first number (for display) var MAXLENGTH=5; function myRowObject(one,two) { this.one = one; // text object this.two = two; // input text object } function deleteCurrentRow(obj) { var delRow = obj.parentNode.parentNode; var tbl = delRow.parentNode.parentNode; var rIndex = delRow.sectionRowIndex; var rowArray = new Array(delRow); deleteRows(rowArray); reorderRows(tbl, rIndex); } function deleteRows(rowObjArray) { for (var i=0; i<rowObjArray.length; i++) { var rIndex = rowObjArray[i].sectionRowIndex; rowObjArray[i].parentNode.deleteRow(rIndex); } } function reorderRows(tbl, startingIndex) { if (tbl.tBodies[0].rows[startingIndex]) { var count = startingIndex + ROW_BASE; for (var i=startingIndex; i<tbl.tBodies[0].rows.length; i++) { // CONFIG: next line is affected by myRowObject settings tbl.tBodies[0].rows[i].myRow.one.data = count; // text // CONFIG: next line is affected by myRowObject settings tbl.tBodies[0].rows[i].myRow.two.name = INPUT_NAME_PREFIX + count; var tempVal = tbl.tBodies[0].rows[i].myRow.two.value.split(' '); tbl.tBodies[0].rows[i].className = 'classy' + (count % 2); count++; } } } function clearTable(option) { var tbl = document.getElementById(TABLE_NAME); if (option != 0) tbl= document.getElementById(LABEL_NAME); //var lastRow = tbl.tBodies[0].rows.length; var lastRow = tbl.rows.length; var i=lastRow-1; while (i>=0) { tbl.deleteRow(i); i--; } } function showRow (val) { var tbl = document.getElementById(TABLE_NAME); var nextRow = tbl.tBodies[0].rows.length; //var nextRow=tbl.rows.length; var iteration = nextRow + ROW_BASE; var row = tbl.tBodies[0].insertRow(nextRow); row.className = 'classy' + (iteration % 2); var cell0 = row.insertCell(0); var textNode = document.createTextNode(iteration); cell0.appendChild(textNode); var cell1 = row.insertCell(1); var txtInp = document.createElement('input'); txtInp.setAttribute('type', 'text'); txtInp.setAttribute('name', INPUT_NAME_PREFIX + iteration); txtInp.setAttribute('size', '77'); txtInp.setAttribute('value', val); txtInp.readOnly = true; cell1.appendChild(txtInp); } function addRowToTable(val,num) { var tbl = document.getElementById(TABLE_NAME); var nextRow = tbl.tBodies[0].rows.length; var iteration = nextRow + ROW_BASE; if (num == null) // appends to the end of the table { num = nextRow; } else // Insert at row num { iteration = num + ROW_BASE; } // add the row var row = tbl.tBodies[0].insertRow(num); // CONFIG: requires classes named classy0 and classy1 row.className = 'classy' + (iteration % 2); // CONFIG: This whole section can be configured // cell 0 - index var cell0 = row.insertCell(0); var textNode = document.createTextNode(iteration); cell0.appendChild(textNode); // cell 1 - input text var cell1 = row.insertCell(1); var txtInp = document.createElement('input'); txtInp.setAttribute('type', 'text'); txtInp.setAttribute('name', INPUT_NAME_PREFIX + iteration); txtInp.setAttribute('size', '62'); txtInp.setAttribute('value', val); // iteration included for debug purposes txtInp.readOnly = true; cell1.appendChild(txtInp); // cell 2 - delete button //----------------------- var cell2 = row.insertCell(2); var btnEl = document.createElement('input'); btnEl.setAttribute('type', 'button'); btnEl.setAttribute('value', 'Delete'); btnEl.onclick = function () {deleteCurrentRow(this)}; cell2.appendChild(btnEl); // Store the myRow object in each row row.myRow = new myRowObject(textNode,txtInp); } function paintTable(index) { var maxLine=index+MAXLENGTH; clearTable(0); // add Row with delete and insert options //---------------------------------------- services=document.forms[0].items.value; if ((services != null) && (services != "")) { var services_array=services.split("|"); sLength=services_array.length ; if (services_array.length < maxLine) maxLine=sLength; // add Row with delete options //----------------------------- for (var i=index; i < maxLine; i++) { val=services_array[i]; //showRow(1,val); addRowToTable(val); } showLabel(index,sLength); } } function showLabel(index,max) { clearTable(1); next_val=index+MAXLENGTH; prev_val=index-MAXLENGTH; var tbl = document.getElementById(LABEL_NAME); var nextRow = tbl.tBodies[0].rows.length; // add Previous and/or Next buttons //--------------------------------- var row = tbl.tBodies[0].insertRow(nextRow); var celNo=0; if (index !=0) { var cell0 = row.insertCell(celNo); var btnEl0 = document.createElement('input'); btnEl0.setAttribute('type', 'button'); btnEl0.setAttribute('value', 'Previous'); btnEl0.onclick = function () {paintTable(prev_val)}; cell0.appendChild(btnEl0); celNo++; } if (next_val <= max) { var cell1 = row.insertCell(celNo); var btnEl1 = document.createElement('input'); btnEl1.setAttribute('type', 'button'); btnEl1.setAttribute('value', 'Next'); btnEl1.onclick = function () {paintTable(next_val)}; cell1.appendChild(btnEl1); } } // end hiding from old browsers --> </script> </script> </head> <body onLoad=paintTable(0)> <form onSubmit="return false" method="post" name="my_form" action=""> <table border= "2" cellspacing="0" id="items_list" > <tbody></tbody> <input type=hidden name="items" value="1|2|3|4|5|6|7|8|9|10|11"> </table> <P><P><table border="1" id="label_list"> <tbody></tbody> </form> </body> </html> Please, help me! Thanks Similar TutorialsCan anyone help me out? I've set up a test site for a project where I have a scrollable table within an iFrame. Techincally, its an iFrame within an iFrame which gets you to a scrollable table I also added an auto-scroll with anchor-links. Everything finally works, but I really want to remove the horizontal-scroll bar that shows up, while keeping the vertical-scroll bar. (Upon testing, I found without the vertical-scroll bar, the anchor-links and auto-scroll don't work correctly.) here's the link to the test site: http://www.thegrandamerican.com/ here's the line of code I think is the correct place to make corrections: <iframe id="myiframe" name="myiframe" src="oprah june 09_news.htm" width="900" height="475" scrolling="yes" overflow-y: scroll></iframe> The hierarchy works as follows: index.htm > spotlight_news.htm > oprah june 09_news.htm The reason for all the iframes is to have elements on the higher pages that will stay in place, such as a music player and dynamic menu bar. other notes and associated files (for the auto scroll) a smooth-src-comments.js smooth.pack.js Thanks. - J Hi Can anyone solve this problem. Here is my 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>Hide/Show Test!</title> <style> .myclass1 { background-color:#CCCCCC; display:block; } .myclass2 { display:none; } </style> </head> <body> <script> function hideNshow(){ var e1=document.getElementById('A1C1_1'); if(e1.className=="myclass1") { e1.className="myclass2"; } else { e1.className="myclass1"; } e1=document.getElementById('A1C1_2'); if(e1.className=="myclass1") { e1.className="myclass2"; } else { e1.className="myclass1"; } } </script> <!-- <input type="button" name="myBtn" value="Click Me!" onclick=" hideNshow();"/>--> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td><a href="#" onclick=" hideNshow();">Row1/Cell1</a></td> <td >Row1/Cell2</td> <td>Row1/Cell3</td> </tr> <tr id="A1C1_1" class="myclass2"> <td>Row2/Cell1</td> <td>Row2/Cell2</td> <td>Row2/Cell3</td> </tr> <tr id="A1C1_2" class="myclass2"> <td>Row2/Cell1</td> <td>Row2/Cell2</td> <td>Row2/Cell3</td> </tr> <tr> <td>Row3/Cell1</td> <td>Row3/Cell2</td> <td>Row3/Cell3</td> </tr> <tr> <td>Row4/Cell1</td> <td>Row4/Cell2</td> <td>Row4/Cell3</td> </tr> <tr> <td>Row5/Cell1</td> <td>Row5/Cell2</td> <td>Row5/Cell3</td> </tr> </table> </body> </html> It is working fine in IE. When I click the link It displays the hidden rows and hides when I click the link agian. But in Firefox it is giving error. It is adding empty rows. How to prevent that. Thanks in advance. Hi guys, I know scroll-bars are automatic when your page gets longer than the screen. I have recently developed a new webpage, and on some pages your required to scroll down, on others you aren't. How do I leave the right hand scroll bar there even if its not required (greyed out) This way my site doesn't seem out of line as they navigate through it. I have a long list (say, 10,000) to be populated in the html select (Multiple with size, say 10 visible at a time) control. I don't want to populate all the items initially. Hence, Initially, I will load top 100 items and whenever user scrolls down and reaches the bottom of the list (say, after crossing 85th item), I want to populate the next 100 items (101th to 200th). I am using javascript to populate the options. The question is: 1. How to identify that the user is reaching the bottom of the control? Is there any way to identify whether a option is visible or not to the user? Thanks in advance, R. Amirdha Gopal. hey guys, i am working on a project for school and trying to go above and beyond the assignment by placing a srollable table data cell in my table. the web page i am trying to make is for "customer contracts" and i would like to have a "description" section but i dont want a lengthy description making my table huge. if someone could tell me how to turn a <td></td> into either a scrollable data cell or maybe even a clickable link that brings up a seperate bigger text box (if its not too much coding) that would be great. heres the code Code: <xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" version="4.0" omit-xml-declaration="yes" /> <xsl:param name="group" select="//person" /> <xsl:template match="/"> <br /> <br /> <table width="370" cellspacing="0" cellpadding="2"> <tr> <th colspan="5">Contract List</th> <th id="total">Total: <xsl:value-of select="format-number(sum($group/amount),'$#,##0')" /> </th> </tr> <tr> <th>Sign Date</th> <th>Start Date</th> <th>Name</th> <th>Address</th> <th>Job Description</th> <th>Amount</th> </tr> <xsl:apply-templates select="$group"> <xsl:sort select="signDate" data-type="text" order="descending" /> </xsl:apply-templates> </table> </xsl:template> <xsl:template match="person"> <tr> <td width="70"><xsl:value-of select="signDate" /></td> <td></td> <td width="100"><xsl:value-of select="last_name" />, <xsl:value-of select="first_name" /> </td> <td width="130"> <xsl:value-of select="street" /><br /> <xsl:value-of select="city" />, <xsl:value-of select="state" /> <xsl:value-of select="zip" /> </td> <td></td> <td width="70" align="right"> <xsl:value-of select="format-number(amount,'$#,##0')" /> </td> </tr> </xsl:template> </xsl:stylesheet> the code i need to modify it the empty <td></td> tags below <xsl:value-of select="zip" /> thanks in advance for any help and if you know of a link that will help me feel free to post that instead of a lengthy response. I need help with making a vertical scroll box w/ table just dont know the html code for a vertical scroll box.. I know the table but i dont think its right. ___ <table border="1"> <tr> <th>Heading</th> <th>Another Heading</th> </tr> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td>row 2, cell 1</td> <td>row 2, cell 2</td> </tr> </table> ___ Thanx in Advance! Good day, I am brand new here in this forum. So many knowledgeable folks here. I am relatively new to web design. I typically use templates and themes and tweak them. I can navigate a CSS doc and html to make changes, etc. However, I have a client who has an existing site that she wants to keep the aesthetic of and so I am using what the previous designer left. It is a simple html page with tables. Simple enough. Very elegant visually. No need to SEO really so it works. She has asked if we can make the left column of a two column table scroll independently. The page content is about over 6000px. The scroll column will contain a page outline and other text that will include internal targeted links. This is outside my skill set, but I want to learn. Have searched the net and found some suggestions but want it to be clean and ended up here. There is no style sheet other than the ie6 sheet. Page is he http://www.themedeaproject.com/proposaltestpage.html no graphics are loaded. Can anyone point me to a good tutorial or have any suggestions? Thanks! BlueEyedMonkey aka Tatyanna Hi all I have attached a screenshot. I want to create table(shown in attachment) with many rows and coloumns(Kind of Xl Sheet) with scroll options. How to insert that table into normal HTML table with width="90%" Kindly resolve this issue. Despite reading multiple posts on "scrollable" table cells on the forums, I've not yet quite found the answer to my question, so hopefully I can get some feedback from all viewers out there! I and some friends run a small Catholic arts and crafts website (www.illuminatedink.com) through which we sell products that we create. I've based the page layout on a table instead of frames or iframes. The table has 3 cells in it. The entire top "banner area" of the screen is one cell. Below that on the left we have the naviagation menu cell. The main content that someone is trying to view appears in the remaining lower right cell (also the largest). This page works great on all the computers at my house (3 of them) and on most other computers as well. I have yet to test this in IE 7.0, but if someone else has that browser, please let me know what happens. So, what's the problem you ask? That lower right table cell where all the content appears does not work for everyone. I just got another complaint today that no scroll bar appears and the person can only see what's in the top of cell, there is no "scrollability". Here is a sample (with notes made by me in ** NOTE ** format). The notes are of course not in the actual code, I am showing only the code really matters here. Code: <BODY STYLE="margin-top: 0px; margin-left: 0px"> <TABLE CELLPADDING=0 CELLSPACING=0 HEIGHT=590 WIDTH=1000> <TR HEIGHT=90> <TD WIDTH=1000 COLSPAN=2 STYLE="background-image:url('http://www.illuminatedink.com/images/background/banner.jpg')">   </TD> </TR> <TR HEIGHT=500> <TD VALIGN=top WIDTH=200 STYLE="background-image:url('http://www.illuminatedink.com/images/background/menu_bar.jpg');background-repeat:no-repeat"> <TABLE ALIGN="center" CELLSPACING=0 CELLPADDING=0> **Navigation menu on the left side goes here** </TABLE> </TD> <TD WIDTH=800 VALIGN="top"> <DIV STYLE="overflow:auto;height:490px;width:800px;position:absolute;left:200;padding-right:30px; padding-left:0px"><MAP NAME="page_links"> **All code for the scrollable cell in the lower right goes here** </DIV> </TD> </TR> </TABLE> </BODY> So, can anyone possibly tell me why this would have a scroll bar in some browers and not in others? Or does anyone have any code changes I could make that may guarantee that they will get a scroll bar in that lower right cell? The complaints that I have received mainly seem to be from Mac users using IE for Mac. But I just had someone who had a brand new Dell with Windows XP Prof. and the most recent IE 6, which is exactly the configuration I run, but didn't get a scroll bar when I did. Ideas? Thank you! I have 10 rows compose of 3 textbox per row. After pressing submit button, they are post to the next page to a table. But my problem is if only 3 rows have data the other rows is still shown in a table but blank with borders. So I want my table to show the rows who only have data It laggs. Meaning it isnt fluent. The site is working fine with all browsers except in IE8 ? In IE I only get a fluent scroll experience when I place the cursor ON TOP of the scroll bar.. now I know this cant be good, so tell me, do I need to add code for IE to recognize my scroll wishes? Have a look at the site here. thank you o btw, for the ones who have helped me in the past have a looksy here! Im growing in knowlegde thanks to you, very much appreciated, feel free to review it and help me improve my coding (because I know it sucks) I have found a problem recently with my photography site where the scroll bar does not show up on the right hand side of the page unless if I am running Safari. I have checked it on other computers and the same thing happens. I think that the big flash app in the middle of the page may be causing it in some way. Anyone got any ideas? Here's the link to my site: http://www.benellett.com/ Hi! I am having problems with horizontal scroll-bar. The thing is horizontal scroll-bar appears in local view. But when I put it into web only horizontal scroll-bar disappears. I'm using swffit also, and tried lots of things to solve this but coulnd't manage to solve this weird problem. Anyone has an idea? Thanks in advance. site link is www.firinciorhan.com.tr I want to dynamically hide column in table. There's many working examples on the web, such as http://www.ahfb2000.com/webmaster_he...ead.php?t=3356 But I lack one feature. When I hide column (all cells in column) via style.visibility="hidden", the remaining column (cells) doesn't adjust its width. I would like to somewhat make the table adjust all cells widths (push together), as if the hidden column (cells) wasn't there at all. Is it possible ? Thanks. Is it possible to set a table's width as something like this? HTML Code: <table width="100%-100px"> Hey... I am working on a site for me and my friends, and I have a question. See this website. As you can see I have used imagemapping to link the area where home is written, to bring you back to the frontpage. I would like to know how i could put a textbox or table inside the white square, or possibly a frame linked to the other sites. Code: Here is my HTML coding:<HTML> <HEAD> <TITLE>Calypto Productions Website</TITLE> </HEAD> <BODY bgcolor= "#000000"> <style type="text/css"> </style> <img src="http://calypto-productions.webs.com/atomicfrsteutkastdz0.png" usemap = #example border=0> <map name=example> <area shape=Rect Coords="262, 125 , 406, 170" Href="http://calypto-productions.webs.com/alt.htm/"> </map> </BODY> i have spent about 45min reading through alot of Iframe related threads but none of them have helped my problem. I have a website with iframes, on my index page i am trying to put an iframe into the content box so when you click the links up top it will load them without refreshing the whole page. So thats fine i put in my iframe code like this <iframe name="homeframe" width="780" height="250" border="0" frameborder="0" marginheight="0" padding="0" marginwidth="0" scrolling="auto"src="homeframe.html"> </iframe> And on the html document im trying to put into it "homeframe.html" it open up but it scrolls horizontally not vertically and all the writing goes onto 1 line horizontally. The width of my content box is 780px so i made the table in the homeframe.html document 780 so it wouldnt have the bar but it does. im stumped. thanks in advance. Just getting my feet wet. using XMLSpy stylesheet designer to help guide. I'm converting XML to HTML, which is Microsoft's recommended way of controlling the import of XML into Excel. I've got the stylesheet below in productive use. However, I want to make one key change. I want the name of XML elements to become the text column headings so I can deal with files that have dynamic column names. Suggestions appreciated. Here is typical XML: <NewDataSet> <Table> <Name>Linda Britt</Name> <RFQCount>324</RFQCount> <RFQResponseCount>556</RFQResponseCount> </Table> </NewDataSet> Here is the stylesheet. See comments regarding what I'm trying to change. <xsl:template match="/"> <html> <head></head> <body> <xsl:for-each select="NewDataSet"> <xsl:for-each select="Table"> <xsl:if test="position()=1"> <xsl:text disable-output-escaping="yes"><table border="0"></xsl:text> </xsl:if> <xsl:if test="position()=1"> <thead> <tr> <td > <span>Buyer Name</span> COMMENT: I want this to be "Name" from element name. </td> <td > <span># RFQs</span> COMMENT: I want this to be "RFQCount" from element name. </td> <td > <span># Responses</span> </td> </tr> </thead> </xsl:if> <xsl:if test="position()=1"> <xsl:text disable-output-escaping="yes"><tbody></xsl:text> </xsl:if> <tr> <td> <xsl:for-each select="Name"> <xsl:apply-templates/> </xsl:for-each> </td> <td> <xsl:for-each select="RFQCount"> <xsl:apply-templates/> </xsl:for-each> </td> <td> <xsl:for-each select="RFQResponseCount"> <xsl:apply-templates/> </xsl:for-each> </td> </tr> <xsl:if test="position()=last()"> <xsl:text disable-output-escaping="yes"></tbody></xsl:text> </xsl:if> <xsl:if test="position()=last()"> <xsl:text disable-output-escaping="yes"></table></xsl:text> </xsl:if> </xsl:for-each> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet> I've searched around quite a bit, read various articles and so-on and only really come to the conclusion that this is a lot harder than it should be! What I have is a simple page for a PHP script, it has a little form for entering keywords, and displays an image above this form. Now, what I want to do is place these in a table, and have that table resize to fit the viewable area of the user's browser-window. So, what I have is a table with three-rows: The title of the image The image itself The form for entering image keywords Now, what I would like to do is have the image scale to fill the middle cell, which by default eats up all available space leftover by the form and title cells. However, this isn't happening, I enter a height of 100% for the image but it seems to be using some other container to get its height. I'm generally well-versed in HTML, but this one has me stumped! Any help is appreciated, here is the basic HTML I'm using for what I had thought would be a simple page Code: <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1" /> <meta name="author" content="Haravikk.com" /> <title>Add keywords</title> <style type="text/css"> body, html { height: 100%; margin: 0; text-align: center; } tr, td, textarea { width: 100%; } table { width: 99%; height: 100%; margin: 0 auto 0 auto; } table, td { border-width: 0; border-spacing: 0; padding: 0; } #image { height: 100%; } #tdTitle { height: 5%; } #tdImg { height: 75%; } #tdForm { height: 20%; } #formText { width: 100%; height: 75%; } </style> </head> <body> <table> <tr> <td id="tdTitle"><b>placeholder.png</b></td> </tr> <tr> <td id="tdImg"> <img id="image" src="http://haravikk.com/placeholder.png" alt="" /> </td> </tr> <tr> <td id="tdForm"> <form action="keywords.php" method="post"> <textarea name="keywords" id="fmrText"></textarea><br /> <input type="submit" /> </form> </td> </tr> </table> </body> </html> Now, I don't know if I could eliminate the table in favour of divs and do this, any suggestions to make the above html work, or to re-write it are welcome! The image provided is just to illustrate the problem Hello, For ages I have been trying to figure out how to add sides to my table, however I can not figure it out, please help. Basically I want side added to the table on this page of my host. - If anyone could help me that would be great. Thanks. |