stuck on a couple of things with javascript

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
garry27
Forum Commoner
Posts: 90
Joined: Sat Oct 14, 2006 1:50 pm

stuck on a couple of things with javascript

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Have you tried looking at the Firebug extension for Firefox. It's DOM inspector is to die for.
Post Reply