JavaScript - Table Content
Hello there, I'm an IT student that recently started to learn JavaScript. I'm trying to write a code that starts with a prompt inputs a number like n. Then the code will ask another n prompts for data input. For example I will input 5 for first prompt, code will ask for 5 more prompts for input. Can't figure out how to do it
Similar TutorialsI'm absolutely new to JavaScript and HTML, although I've done a fair amount with Visual Basic (VB6 and macros in Word and Excel). I'm trying to create a form with different sections. When the user checks a checkbox for a section, the table with the input areas for that section will appear; if the user changes his mind and unchecks the box, that table will go away. I've played with the visibility attribute, and that works - sort of. I can hide the table from view, but it's still there in the page, taking up as much room as it does whether visible or not. There's a big empty gap containing an invisible table or two if the user only selects the third or fourth section. Code: function showhide(element){ if(document.getElementById(element).style.visibility=="hidden"){ document.getElementById(element).style.visibility="visible"; document.getElementById(element).style.display="block"; }else{ document.getElementById(element).style.visibility="hidden"; document.getElementById(element).style.display="none"; } } And I played with the height attribute, and that works - to a point. I can only collapse the table ror height when there's nothing in it. But if there's text, or a text box, or a textarea box, the row will not go down to zero, even if that's what I set it to. Code: <tr ID="targetrow" style="height:0px;"></tr> I'm hoping the only solution isn't to write the table into the document on the fly when the box is checked, and then delete it if the box is unchecked. Any help? Ed Hello, I am trying to move each cell content from one table to another table. I do not want to lose the value of each cells in table1, but just to show how I got table2 from table1. I would like to show/animate the movement. So when the user clicks the button the data from table1 will scroll towards table2. I am new to HTML/javascript programming I really appreciate your help Hi Guys, i am wondering if there is a way to have an auto Complete form field from a db table data ? thanks Hi all, I am using xmlhttp.open();xmlhttp.send(); to send a php content to a div. This php content is again using the same method to get php content from a further page. The content of the div, does not seem to be using the css and javascript files defined in the calling pages <head> section. Does anyone know why this is? Is there a workaround or solution to this problem? It might be easier to understand looking at the code, so Background info: Javascript file: scripts.js client.php ----> loads data from: display_client.php display_client.php ----> loads data from: display_brand.php Code: client.php http://pastebin.com/4EFn9YRf display_client.php http://pastebin.com/BGZAKre2 display_brand.php http://pastebin.com/0a4Pg3gg scripts.js http://pastebin.com/er4dkmPc Thanks! Ok, I would post my entire data here but then yall would be reading insane amounts of script. I've got a div content jquery slider on my site I am making and it works beautifully in all browsers(took me a while). Then, I decided why not have it where when people click on a "read more" link that it pops up a box, instead of directing to the new page, and displays the contents of a div. It would not work at all. My question is there a possible way to do this?
My issue is that I have a javascript function applied on page load via an addLoadEvent function call in the head to every row (dynamic number of records retrieved) on a table. On every row of the table I also have an element (image or button) that performs a different function that is assigned on the element itself. Unfortunately, when I click the element it also performs the function that was applied to the row in the page load. Is there any way to not call this function on element click? I know usually you include code, but due to the nature of the work I am limited in that respect. Basically its: Code: <script type="text/javascript"> addLoadEvent(function() { function1(1); }) //function1 makes the table rows do something appearance wise. </script> <tr> <td></td> <td></td> <td> <img src="pics/delete.png" alt="Delete" onclick="function2();"> </td> </tr> I apologize if my post doesn't conform to the general guidelines of proper posting on this board. I'm new on this site. Hello all i have to implement simple LIFO algorithm ( if i can call it like this .. ) say i have html table and and i fetching data i like thet the last data that fetched to be the first record in the table for example : im fetching the string "111" so it will be the first record next im fetching the string "222" now the string "111" will be the second and the string "222" will be the first .. and so on hi guys i having some problems with jquery plugin table sorter on a dynamic table. if i use it on a regular html table it works fine,but on my dynamic table its not working. if someone could look at my code and see if i done something wrong i would appreciate it . Thanks will43 Code: <script type="text/javascript" src="table sorter/jquery.tablesorter/jquery-latest.js" ></script> <script type="text/javascript" src="table sorter/jquery.tablesorter/jquery.tablesorter.js" ></script> <script type="text/javascript"/> $(document).ready(function() { $("#myTable").tablesorter(); } ); </script> <form id="form1" name="form1" method="post" action=""> <label for="Position">Position</label> <select name="Position" id="Position"> <option>QB</option> <option>HB</option> <option>FB</option> <option>WR</option> <option>TE</option> <option>RG</option> <option>RT</option> <option>C</option> <option>LG</option> <option>LT</option> <option>CB</option> <option>LB</option> <option>SS</option> <option>FS</option> <option>DE</option> <option>DT</option> <option>P</option> <option>K</option> </select> <input type="submit" name="Summit" id="Summit" value="Submit" /> </form> <p> </p> <p> </p> <table width="950" border="1" cellpadding="3" cellspacing="3" class="tablesorter" id="myTable"> <thead> <tr> <th bgcolor="#FF0000">id</th> <th bgcolor="#FF0000">Team</th> <th bgcolor="#FF0000">FirstName</th> <th bgcolor="#FF0000">LastName</th> <th bgcolor="#FF0000">Position</th> <th bgcolor="#FF0000">Year</th> <th bgcolor="#FF0000">Overall</th> <th bgcolor="#FF0000">Speed</th> </tr> </thead> <?php do { ?> <tbody> <tr> <td bgcolor="#FFFF00"><?php echo $row_Recordset1['id']; ?></td> <td bgcolor="#FFFF00"><?php echo $row_Recordset1['Team']; ?></td> <td bgcolor="#FFFF00"><?php echo $row_Recordset1['FirstName']; ?></td> <td bgcolor="#FFFF00"><?php echo $row_Recordset1['LastName']; ?></td> <td bgcolor="#FFFF00"><?php echo $row_Recordset1['Position']; ?></td> <td bgcolor="#FFFF00"><?php echo $row_Recordset1['Year']; ?></td> <td bgcolor="#FFFF00"><?php echo $row_Recordset1['Overall']; ?></td> <td bgcolor="#FFFF00"><?php echo $row_Recordset1['Speed']; ?></td> </tr> </tbody> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table> hi all, i have a table, just a basic table with 6 rows. depending on the value of the first <td>thevalue</td> i want to start a end the existing table and start a new one. the newly added table (i hope) will contain all the remaining <tr><td></td></tr> nodes until i run into the next check that will close the newly added table and begin a new table again etc.... i can get the correct node (tr) after i find the value in the td im looking for, and then try a : document.createElement("table"); , but my problem is that this newly created table tag comes with an automatically created </table> element / tag, so i end up with just inserting a new blank table after a row instead of inserting a new table tag that has all the remaining tr and tds under it. hope that makes sense. my entire test page is: (click the text link and an alert will show the output with the new <table></table> after the row that my check is looking for (first td with a 2) -------------------------------------------------------------------- Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> <script type="text/javascript"> function reformatMe() { var divObj = document.getElementById('reformatMe'); var numRows = document.getElementsByTagName("tr"); var z = "1"; for (i = 0; i < numRows.length; i++) { if (numRows[i].childNodes[0].innerHTML == "2") { var markStart = numRows[i]; alert(markStart.nextSibling); var closeTable = document.createElement("/table"); var addTable = document.createElement("table"); //var tbody = document.createElement("tbody"); //addTable.appendChild(tbody); addTable.setAttribute("id", "subOptionID" + z); if(numRows[i+1] != null){ numRows[i].parentNode.insertBefore(addTable, numRows[i+1]); } z++; } } alert(divObj.innerHTML); } </script> </head> <body> <a href="#" onclick="reformatMe();">reformat table</a> <div id="reformatMe"> <table border="1" cellpadding="4" cellspacing="2" id="menuItemID1"> <tr><td>1</td> <td>1</td> <td>How would you like your food prepared?</td> <td>1</td> <td>1</td> <td>0</td></tr> <tr><td>1</td> <td>1</td> <td>Choose two of the following sides</td> <td>0</td> <td>2</td> <td>0</td></tr> <tr><td>1</td> <td>1</td> <td>What do you want on your Baked Potato?</td> <td>0</td> <td>2</td> <td>1</td></tr> <tr><td>2</td> <td>1</td> <td>What type of dressing do you want on your salad?</td> <td>1</td> <td>1</td> <td>1</td></tr> <tr><td>1</td> <td>1</td> <td>Do you want fries?</td> <td>1</td> <td>1</td> <td>0</td></tr> <tr><td>1</td> <td>1</td> <td>Do you want ketchup on your fries?</td> <td>1</td> <td>1</td> <td>1</td></tr> </table> </div> </body> </html> Hi guys, I am working with a plugin calld Hashslider which is a fairly simple div slider. Here is the code for startrs Code: // hashslider v0.9 by manuel huegel, copyright 2010 // mgoys.com $(document).ready(function(){ //get width and height of the wrapper and give it to the UL var wrapperwidth = $('#slider').width() * $('#slider ul > li').size(); $('#slider ul').css('width', wrapperwidth); var wrapperheight = $('#slider').height(); $('#slider ul').css('height', wrapperheight); //set my li width var width = $('#slider').width(); $('#slider ul li').css('width', width); //set my counter vars var counter = $('#slider ul > li').size(); var decount = 1; var autocount = 1; //create my number navigation var createNum = 1; $('#numbers li:first-child').html(createNum).addClass('activenum').attr('id', 'id1'); while ( createNum != counter) { $('#numbers li:last-child').after('<li> </li>'); createNum++; $('#numbers li:last-child').html(createNum); $('#numbers li:last-child').attr('id', 'id' + createNum); } //get my number-width (number navigation should always be centered) var numwidth = $('#numbers li:first-child').width() * $('#numbers li').size(); $('#numbers').css('width', numwidth); //slide the button to the next item function goNext() { if ( decount != counter) { $('#slider ul').animate({ left: '-=' + $('#slider').width() }, 400, 'swing', function() { }); $('.activenum').removeClass('activenum').next().addClass('activenum'); decount++; window.location.hash = decount; } } function goBack() { if ( decount != 1) { $('#slider ul').animate({ left: '+=' + $('#slider').width() }, 400, 'swing', function() { }); $('.activenum').removeClass('activenum').prev().addClass('activenum'); decount--; window.location.hash = decount; } } //make the number clickable $("#numbers li").click(function() { //$('#info4').html( $(this).html() ); var clickednum = $(this).html() * - $('#slider').width() + $('#slider').width(); //$('#info4').html( clickednum ); $('#slider ul').animate({ left: clickednum }, 400, 'swing', function() { }); $('.activenum').removeClass('activenum'); $(this).addClass('activenum'); decount = $(this).html(); window.location.hash = $(this).html(); }); //thaths the hash-shizzle if ( window.location.hash != '') { //get hash, scroll to position var hashnum = window.location.hash.substr(1) * - $('#slider').width() + $('#slider').width(); $('#slider ul').animate({ left: hashnum }, 0, function() { }); //set counters to position decount = window.location.hash.substr(1); $('.activenum').removeClass('activenum'); var hashname = window.location.hash.substr(1); $('#id' + hashname).addClass('activenum'); } //get my clickers $("#right").click(function() { goNext(); }); $("#left").click(function() { goBack(); }); //get mousewheel function $("#slider ul").mousewheel(function(event, delta) { if (delta > 0) { goBack(); event.stopPropagation();event.preventDefault(); } }); $("#slider ul").mousewheel(function(event, delta) { if (delta < 0) { goNext(); event.stopPropagation();event.preventDefault(); } }); }); As you will see the current code loops through all of the slides, and when it reaches the last (or first) the previous and next links become unclickable. I would like to go a stage further than this and make them dissapear entirely. I don't know how to do this or even to start, I dont even know what function to edit. Please help guys. Thanks in advance Dan What wrong in this code? Code: <script type="text/javascript" src="jquery.js"></script> <script> $(function (){ function manda(){ var text = $('#frame').contents().find('p[class=no_boder]').html(); $('div').html(text); } }); </script> i've already tried using this -> $('#frame').contents().html(); How can i get the content? I can't really get any help over on the greasemonkey forums so hopefully I can get some needed help here. My goal with a script I am writing is to remove signatures from a forum I am a part of. Some of the people abuse it with half a page of stuff and it's out of control. So here is what the HTML source code for it looks like Code: <table cellSpacing="1" width="100%" border="0" class="tback" cellPadding="2"> <tr> <td width="100" class="headcell">Author</td> <td class="headcell">Topic</td> </tr> <tr vAlign="top" class="cell"> <td align="center"> <div><a href="profile.asp?$sid=&id=5126">Roadwildcat</a></div> <div class="fcaption">Pee Wee League</div><br><div><img src="images/stars-2.gif" alt="2 Stars"></div><br><img src="Avatars/Georgia.gif" alt="Member Avatar" height="62" width="62"><div class="fcaption">DC Georgia 2020 to Present</div> <div class="fcaption">115 Posts</div> </td> <td> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td><span class="fcaption"><img src="images/oPost.gif" alt="Old Post" height="10" width="10" border="0" align="absmiddle">Posted - 03 January 2011 5:41</span></td> <td align="right"><a href="myForum.asp?$sid=&mode=compose&to=5126"><img src="images/pm.gif" width="33" height="18" border="0" hspace="3" align="absmiddle" alt="Send Roadwildcat a Private Message"></a><a href="post.asp?$sid=&mode=Quote&id=24958&fid=2&t=24958&fpage=1"><img hspace="3" alt="Reply With Quote" src="images/quote.gif" width="28" height="18" align="absmiddle" border="0"></a></td> </tr> </table> <hr size="1" noshade>I have been trying to set my attendance to the all star games but when I do a game search on the map it is showing no games at all. Anyone else having this problem?<hr size="1"><span class="fcaption">SEC Champions 2022-2027 <br/> National Runner-up 2027 <br/> Recruiting BEAST! <br/> BULLDAWG BOUNCE</span></td> </tr> The very bottom where it has the 'span' tag and it says "SEC Champions" is where the Signatures are located. I want to completely remove that using my script and this is what I have right now Code: function sigRemove() { var sigs = document.getElementsByTagName('span'); for (var i = 0; i < sigs.length; i++) { sigs[i].style.display = 'none'; } } I know it's incomplete but I only want to remove that bottom span tag and everything inside of it and not every span tag on the page. Please help and I apologize for the long post Hello, I have been using interstitial boxes for quite a while and have never had a problem. I was required to create an interstitial box this week. When the home page is display in Firefox and Safari, the interstitial box displays right away as it is supposed to do; however, it will not display in Internet Explorer 7 unless you refresh the screen. Is this a known problem? Is there a way of correcting this? [URL] http://jpl.coj.net [URL] Thank you for your help, Elbee I am using a Theme Tester on my site so normal users can not see the changes being made. If you can help me, please send me a PM & I will give you a temporary login so you can login & see the new site, and the issue I am having. Basically, I am trying to get this http://flowplayer.org/tools/demos/sc.../navigator.htm scroller to work, but it is not happening at all. Not sure what is going on. Please advise. Thanks! I am creating a testimonials page on a customers site, and I am wanting it to be like a scrolling content. I have the border created, and I want to have text inside the border that will scroll sideways displaying a new one every 10 seconds or so, but having the ability to move between the content. Can anyone tell me what sort of script I should use? I've seen something like it before, but I've had a mind blank. I know it's some kind of Java scripting. Any ideas? Thanks in advance I realy did not mean over image I ment some like "text"<br> then image here there are 4 parts to this script. I am trying to change it so that there is text content over the image. part 1 Code: meta http-equiv="imagetoolbar" content="false" /> <link rel="stylesheet" href='slideshow1.css' type="text/css" /> <script type="text/javascript" src="xfade2.js"></script> <div id="rotator"> AD One<a href="$siteurl/index.pl" onmouseover=\"Tip('<img src="/upload/3282.jpg" width="300">')\" onmouseout=\"UnTip()\"><img src="imageone.jpg" width="120" height="90" border="0" alt="2 bed/1 bath House" /></a> Ad TWO1<a href="$siteurl/index.pl" onmouseover=\"Tip('<img src="/upload/2485.jpg" width="300">')\" onmouseout=\"UnTip()\"><img src="imagetwo.jpg" width="120" height="90" border="0" alt="CSS Beauty" /></a> </div> the "AD ONE" and "AD two" Content above is what I would like to show up over the image and roate with it. I think I just need to change something in part 4 of the code but not sure were. part two slideshow1.css Code: * { margin: 0; padding: 0; } #rotator { border: 1px solid #000; cursor: pointer; overflow: hidden; margin: 50px auto 10px; position: relative; width: 120px; height: 90px; } #rotator img { border: 0; cursor: pointer; width: 120px; height: 90px; } p { text-align: center; } part 3 slideshow2.css Code: #rotator img { display: none; position: absolute; top: 0; left: 0; } part 4 xfade2.js Code: /* Image Cross Fade Redux Version 1.0 Last revision: 02.15.2006 steve@slayeroffice.com Rewrite of old code found he http://slayeroffice.com/code/imageCrossFade/index.html */ window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init); var d=document, imgs = new Array(), zInterval = null, current=0, pause=false; function so_init() { if(!d.getElementById || !d.createElement)return; css = d.createElement('link'); css.setAttribute('href','slideshow2.css'); css.setAttribute('rel','stylesheet'); css.setAttribute('type','text/css'); d.getElementsByTagName('head')[0].appendChild(css); imgs = d.getElementById('rotator').getElementsByTagName('img'); for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0; imgs[0].style.display = 'block'; imgs[0].xOpacity = .99; setTimeout(so_xfade,3000); } function so_xfade() { cOpacity = imgs[current].xOpacity; nIndex = imgs[current+1]?current+1:0; nOpacity = imgs[nIndex].xOpacity; cOpacity-=.05; nOpacity+=.05; imgs[nIndex].style.display = 'block'; imgs[current].xOpacity = cOpacity; imgs[nIndex].xOpacity = nOpacity; setOpacity(imgs[current]); setOpacity(imgs[nIndex]); if(cOpacity<=0) { imgs[current].style.display = 'none'; current = nIndex; setTimeout(so_xfade,3000); } else { setTimeout(so_xfade,50); } function setOpacity(obj) { if(obj.xOpacity>.99) { obj.xOpacity = .99; return; } obj.style.opacity = obj.xOpacity; obj.style.MozOpacity = obj.xOpacity; obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')'; } } I work for a certain print and online publication. The one problem we have is other sites copying ad pasting our content to thier own websites or blogs. Wondering if theirs some way to allow a user to only to be able to copy/paste a certain character limit and then somehow add link to copied and pasted blurb? Maybe theirs a way to use javascript to command notepad to only allow a set number of characters.... Maybe theirs a service available or should be. Hi, Well this plugin stops working after completely loading the flash content or game. I did a few changes to it but still, it won't show the game after completely loading the flash. Can someone tell me what's wrong? Here is the link to live working example http://files.cryoffalcon.com/Piecema...s/testing.html |