![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| [SOLVED] Why Javascript function doesn't work in my program? Hi Friends, Currently I'm working in the struts 1.1 envi. I am using layout tag to create the dynamic multiple columns table. In which I include the one more functionality called selectable row in a table. For this I have the javascript function. When I run the project, the javascript which i wrote for select a row with certain color is not working. Please refer me what is the problem I am facing. I have attached my javascript program here: <script type="text/javascript"> var lastSelRow = null;var node = null; function changeRowColor(node){unSelect(); children = node.getElementsByTagname("td"); alert("I'm an alert box!"); for(i=0;children.length();i++){ children[i].style.backgroundColor = '#FBE797'; }lastSelRow = node;} function unSelect() {if(lastSelRow){ children = lastSelRow.getElementsByTagName("td"); for(i=0;i<children.length();i++){ children[i].style.backgroundColor = '#FFFFFF'; }} lastSelRow = null;}</script> |
| |
| |||
| In function changeRowColor, you have this: for(i=0;children.length();i++) children.length() is defined as true (by definition) as long as it doesn't equal 0. Does it ever equal zero? Nothing in your code suggests that anything ever happens to make it equal to 0. Did you mean, as you typed in the function unSelect below, for(i=0;i<children.length();i++) Also, its probably not a good idea to call unSelect() at the beginning of changeRowColor() unless you've defined it first. Javascript is not a strongly typecast language, but you should still be in the habit of defining things before you use them. I hope this helps. |
![]() |
| Thread Tools | |
| Display Modes | |
| |