deleteRow() not working

I have two scripts. The first script creates a row in a table: function addRow(tblId) { if(counter == limit) { alert("You cannot add more than " + limit + " passages!"); } else { var tblBody = document.getElementById(tblId).tBodies[0]; var newNode = tblBody.rows[0].cloneNode(true); tblBody.appendChild(newNode); counter++; } }
... the second is supposed to delete the last row created (and subtract from the max rows count): function deleteRow(tblId) { var tblBody = document.getElementById(tblId).tBodies[0]; var lastRow = document.getElementById(tblId).rows.length; if(lastRow == 1) { alert("Cannot delete first row!"); } else { tblBody.deleteRow(lastRow); counter = counter - 1; } }
However the deleteRow function is NOT deleting rows (when I push the button with the onclick=deleteRow('scripturetable') ). I know the function is being called, as, when there's only one row, the alert pops up, but that's it.

Posted On: Sunday 25th of November 2012 09:02:37 PM Total Views:  142
View Complete with Replies

Related Messages:

javascript code not working in firefox   (382 Views)
Your code is far from being a proper XHTML document, but works in IE, since its really forgiving. A few things: the form elements should go in the form tag. Its only when they go inside the form tag, a name attribute given to them is valid, otherwise name attribute for non-form elements is deprecated. The language attribute of tag is deprecated. Use 'type ' instead. Something like . Its always recommended to place your script in the header section or include it at the bottom of your page. The way you are accessing the elements is completely wrong. One possible way would be to just pass the form element to the validate function and let the function pull out values from the form. Something like this: I would recommend you to get hold of a good tutorial (google is your friend) and start some serious reading., thanks got it working.... another thing, can you tell me how to get a login dialog box at the start i.e "on loading" of a page, Erm.. not using javascript. It's not a good way to adequately password protect pages. The best you can do with javascript is: - hide everything but the password form on the page (wrap everything in an html element, set display:none; or visibility:hidden; in css) unless the user enters the correct password (then set everything visible, using display:; or visibility:visible; respectively). unfortunately, everything on the page can be seen using view > source. - have the page redirect when the user enters the correct password ( as you're doing here ); again, anyone can look at the source, and find out the URL of the restricted page. - the best javascript 'password protection' i've seen did this: have a page with a password form; when the user enters anything in the password field; the script redirects to a folder with the name of the correct password; the basic principle is, that it's difficult for the average user to know where the folders on a webserver are, unless you give some hint ( links, common folder names, etc ). every incorrect guess will redirect to some unmapped location on your server; not ideal, but it restricts access. the bad point here, is that any user watching an 'admin' can see what the password-named folder is.. but, it's the best javascript password restriction method that I can imagine. You could take it a step further, and transform the password entered by some text/ascii math function before redirecting, but, the script suffers from the same vulnerability I mentioned if someone sees an admin login, although, its less obvious if the function generates some long non-dictionary string of characters. the real solution, is not to use javascript for password restriction. use some method server-side that only sends pages to users that are authorized. aswell as a good set of tutorials for javascript, some for basic server side authorization, and somewhere in there the client-protocol-server relationship, would be quite useful... If you want to go ahead with JS validation regardless of that advice, and you just want an input dialog to pop-up; this code _should_ do that: I haven't tested it atall, but it looks alright, although it's old-school quirks mode HTML. It would need the same fixes as s.o.s mentioned with regard to your posted code in order to make it 'new standards compliant'
Help! Tab content not working in FF   (93 Views)
I'm having problems with a tab content script/css in the way it displays in Firefox. It looks perfectly alright in IE, but in Firefox the big shaded tab on the far right just wouldn't line up. I have used 'html>body' for Firefox so the layout in IE remains unchanged. However, no matter how I try to extend the last tab out, anything over the padding margin set currently, the last tab gets swipe down below. However, the code in Firefox works without a table enclosing it like this one: I noticed that if you click on the last tab, there's an extended invisible margin to the right of it. That could be the reason why the tab pushes down when placed in a set table width. As I'm not allowed to redesign this, plus I'll probably burn in hell for using DIVs with tables. My question is, why does Firefox render the code like that, is there something I can do to fix this so it lines up properly like it does in IE I'll appreciate any help I can get. Thank you very much. (This tab content script was taken from Dynamic drive. It uses a JS file and CSS. ) Below is the CSS that the tab panel uses (for Firefox) .shadetabs1{ padding: 0px 0px -5px 0px; margin-left: auto; margin-right:auto; margin-top: 0px; margin-bottom: 0px; font: bold 15px tahoma; list-style-type: none; text-align: left;/*set to left, center, or right to align the menu as deed*/ } html>body .shadetabs1 li{ display: inline; margin: 0; margin: 5px 19px 5px -40px; } html>body .shadetabs1 li a{ text-decoration: none; position: relative; z-index: 1; padding: 19px 62px 4px 20px; margin-right: 5px; border-bottom: 0px solid #778; color: #2d2b2b; width:206px; background-image: url(images/tab_up.jpg); background-repeat:repeat-y; } .shadetabs1 li a:visited{ color: #2d2b2b; } .shadetabs1 li a:hover{ text-decoration: underline; color: #2d2b2b; } .shadetabs1 li a.selected{ /*selected main tab style */ position: relative; width:1px; top: 0px; } .shadetabs1 li a.selected{ /*selected main tab style */ background-image: url(images/tab_down.jpg); border-bottom-color: white; } .shadetabs1 li a.selected:hover{ /*selected main tab style */ text-decoration: none; }
AJAX / XMLHttpRequest working in all browsers except?   (97 Views)
Hi i am new to AJAX but i havejust managed to write one of my first basic scripts. What it does is takes all the news items out of a database and lists them as links. When you click a link i want all of the data that is linked to that news item to display underneath. Now i have got this to work except it will not work in Firefox, all other browsers it is fine. Below is the code i have written, Could anyone please help.
please help ,simple js not working   (267 Views)
It doesn't work because you don't need to surround the link with script tags for that inline javascript to work. The click this link will work just fine on its own.
reset list box is not working javascript   (81 Views)
Hmm it says SCRIPT ERROR when i click RESET (Nothing else happens) Hmmm,looks good though!
Can't put 2 Javasript working in the same page!   (115 Views)
I am working on a website and I dont know much of Javascript,but I need to put to work different scripts on the page,and it wont work!:sad: I've already try to chage all that I remeber to chage,but dosen't work!What I am doing wrongCan anybody help me out Here is my code: window.onload = function() { // Pick your classes var myBox = document.getElementsByClassName('box_title'); var myBoxOpen = document.getElementsByClassName('information'); // Create the accordion var myAccordion = new fx.Accordion( myBox, myBoxOpen, { onActive: function(tog){ tog.setStyles({color: '#fff', background: '#840000'}); }, onBackground: function(tog){ tog.setStyles({color: '#b7d30b', background: '#7d8c87'}); }, alwaysHide: true } ); } function MM_callJS(jsStr) { //v2.0 return eval(jsStr) } $(document).ready( function(){ $('ul#hFade').innerfade({ speed: 7000, timeout: 13000, type: 'sequence', containerheight: 'auto' }); });
IE 7 and existing online ordering system not working   (97 Views)
I need someone to point me in the right direction or just hit me over the head and tell me what I need to do. I feel comfortable doing the html coding - javascript is not my friend as of yet -- but I am working on that. The other programmers here have embraced it faster than I have but they do not know the answer either. We have an existing online ordering system that works great in IE6 but now the drop downs are doing strange (unwanted) things. In one instance the box will not stay open unless you right click on it first. In the others (which are many) the box opens and you can make a selection but then your mouse is disabled on this page for minutes at a time. The way around that is to get focus off of that page. I know there is an issue with the onblur() event but I don't know what it is or how to solve it, and I don't know if that is the only issue.
javascript image animation not working????   (223 Views)
Javascript not working under Mac! Why O why?!   (63 Views)
, I have a javascript code (a part of it is in php) that populates a pull-down menu. It works perfectly well with Explorer, Netscape and Firefox under Windows. But impossible to make it work with Explorer or Safari under Mac!!! Is javascript different between windows and mac Here's the code, if anyone has the slightest idea or suggestion.
Javascript is not working in IE6   (121 Views)
I have created a web page with javascript, its successfully working in firefox but not in internet explorer version 6 and 7. I am not good in scripting and I have done this page with the help of my friend. I have uploaded the zip file. It contain two directories one is for web page (php_files) other for support file (Support_Files). Please unzip the file and test the page. I have also uploaded my browser output for Firefox and Internet explorer. My apologize I have not shared my original page, this is the test page. Please help me and also let me know if you need any more information regarding the same.
resize not working   (141 Views)
i am trying to resize a button using the following code and it has had no effect on the button it has remained the same size.
JavaScript not working in Internet Explorer 7   (120 Views)
Firefox vs. IE-menu not working please help   (233 Views)
; I hope an experienced person can help me. Our site: has a top menu that currently works in Internet Explorer but does not in Firefox. I have used HTML Tidy for my index page and now it looks ok in Firefox but not IE. I have reverted back to the original index which works in IE. I have three CSS files, one Javascript and the index page. I am a bit new at this and really need someone to take a peek at the files and please tell me where the code needs to be modified so it will work in IE and Firefox. I am hoping a "guru" can share their wisdom and help me get this menu functioning. I have attached the files in Word because of the restrictions. The link to our site, has the index page that is rendering correctly in IE but not Firefox. I really appreciate any and all help.. I great
my html code isnt working please help   (368 Views)
overlay not working in IE's   (145 Views)
HI there, I have runt into an issue with the overlay I have on the website I am working on The problems seem to be with Internet explorer 7, 8 and 9. Say you click on the first thumbnail, then the big pix comes up and behind it the overlay. Then close this picture and click on the next one: the overlay is now solid black. Basically it works fine with the first image but then any subsequent image seems to throw it. I am aware of IE's not being able to handle the opacity therefore in my css I have this: .overlay { display:none; background-color:black; position:fixed; opacity:0.75; filter:alpha(opacity=75); /* For IE8 and earlier */ top:0; bottom:0; right:0; left:0; width:100%; z-index:100; } But despite this it doesn't work. I thought that maybe, it isn't the css but the script that handles the big images but still I couldn't find anything wrong with it...maybe you can Here's the script: var $full_images; var $close_button; var $overlay; $(function(){ $full_images = $(".full_images"); $close_button = $(".close_button"); $overlay = $(".overlay"); $the_pic = $(".image_div"); }); function change_images(image, text){ var $images = $("#" + image); var $description = $("#" + text); $overlay.hide().show(); $the_pic.hide().show("slow"); $full_images.hide().show("slow"); $images.hide().fadeIn(1000); $description.hide().fadeIn(1000); $close_button.hide().show(); $close_button.unbind('click').click(function(){ $(this).hide(); $images.fadeOut("fast"); $description.fadeOut("fast"); $full_images.hide("slow"); $overlay.hide("slow"); $the_pic.hide("fast"); }); } A note on the script: the variable $the_pic is there in error it hasn't actually been declared, but I doubt this can be the problem because the overlay isn't working in previous versions of the script without the variable ANy idea at all what could cause that
jScrollPane not working   (137 Views)
I am trying to use jScrollPane vertically, but it is not working. I want simple styleable scrollbar alternative for above link or need help to make code work ( Vertical only :- )
options and buttons not quite working correctly in?   (139 Views)
In my jsfiddle I have an application where the user can select an option and their answers and then display it in a new row. I have one slight problem though, I think it will be easier to explain if you follow the steps below in my [fiddle][1]: 1. Open the grid and select option "3". "3" would be displayed in the textbox and buttons "A" to "C" would appear 3. Click on "Add Question" button. This would create a new row showing the details you have submitted. 4. Now click on the "Open Grid" WITHIN THE ROW you have justmcreated and select option "5". Now the textbox within the row changes the value from "3" to "5" but if you look at the top where you first chose your options and answers, it displays 5 buttons from "A" to "E". This should not happen. This should stay to what it was previously which was buttons "A" to "C". it should only change if the option is chosen from the Option Type at the top and not within the row. So how can this be fixed Please use the fiddle to test your ideas if it helps you. Thank you [1]:
click function not working   (283 Views)
why isn't this working $('body').find(".overcolor").click(function(){ alert("hi"); });
jquery ajax not working   (195 Views)
ok so i am using jquery ajax to send post data to the php page to get processed. since im using a textarea with an editor on it i have to call the content like so var content = $('#pagecontent').val(); then post it through to the php page. which works but it seems to have a problem with a an & symbol in the post data. it cuts off the rest of the code after an & symbol. when get the contents of the textarea with console.log($("#pagecontent").val()) it grabs all the content. Even the content after the & symbol. then i post it through and have php output the contents that is submitted and then i see that the rest of the content after the & is gone. So the problem that i am having is why is the ajax posting cutting off my content after an & symbol. it seems to grab the content fine before the submitting.
Selecting at least one field is not working   (174 Views)
Hi to all i have done validation on single fields but i have to apply validation on 3 text field that at least one of thre is filled .i make a code but that logic doesnot work .. html code ID Technologies First Name: Last Name : Organization Name: Email: Contact Number: Duration in years: Extend Read Only Download link MAC ID: CPU ID: MotherBoard ID: js code function validate_required(field,alerttxt) { with (field) { if (value==null||value=="") { alert(alerttxt); return false; } else { return true; } } } function validate_email(field,alerttxt) { with (field) { apos=value.indexOf("@") dotpos=value.lastIndexOf(".") if (apos