Page 1 of 1

stuck on a couple of things with javascript

Posted: Mon Feb 05, 2007 4:30 pm
by garry27
hi guys!

i was hoping you could help me out on a few questions. i appreciate the help.


1. i'm trying to remove a style class from an object like this

Code: Select all

whichrow.removeClassName('selrow');
but i'm getting told that line isn't a function. whichrow is the row reference

2. i'm trying to delete a row in a table using a row reference passeed into a function but rather than delete the row who's onclick event called the function, it deletes the first row at the top of the table. i don't know why this is because the rest of my move row control structures use the same refereence and they act fine:

Code: Select all

 //x indicates the row which called the function
function moveRow(x){
  if (whichrow) {
   ..
    else if (x=='down'&&whichrow.nextSibling)
      whichrow.parentNode.insertBefore(whichrow.nextSibling,
       whichrow);
    else if (x=='remove')
      whichrow.parentNode.deleteRow(whichrow);
...

3. finally is this syntax ok, because it will only pass variables if they're in numeric form, string values throw back errors:

Code: Select all

document.getElementById("pp-div2").innerHTML ="<a href='#' onClick='addPubFn(" + pubID + "," + pubName + "," + pubPostcode + "); return false;'>Add to Pub Crawl</a>";	  
      changeBodyClass("pp-div2-hide","pp-div2-show");


thanks for reading

garry

Posted: Tue Feb 06, 2007 11:34 pm
by RobertGonzalez
Have you tried looking at the Firebug extension for Firefox. It's DOM inspector is to die for.