ozzie135 Posted September 5, 2007 Share Posted September 5, 2007 Can anyone please tell me why the below isnt working? I'm trying to create a read through the rows in a database table and create a dynamic html table (using php). The id of each row must be the id ($row['id']) of the row returned. Ive tried everything and nothing is working. tried this echo "<tr id="'<?php echo $row['id'];?>'"><td align=\"left\">"; and this echo "<tr id="'.$row['id'].'"><td align=\"left\">"; and other combinations. Just seems its never getting set. No errors are being thrown, just the element id doesnt exist when I use javascript to get the element by id. If i hardcode it, it works. Any help will be greatly received. Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 5, 2007 Share Posted September 5, 2007 http://www.phpfreaks.com/forums/index.php/topic,6264.0.html Obviously the $row['id'] is not set. We need to see more code. Quote Link to comment Share on other sites More sharing options...
ozzie135 Posted September 5, 2007 Author Share Posted September 5, 2007 The $row['id'] variable is set. I have echoed it to the page and it is correct. Im also using the id to delete the contact from the database. I now feel that the id is definitely getting set, and the problem has been narrowed down to this: var response = xmlHttp.responseText; hideElement(35); My hide element function simply hides the element that it is given. The above example shows that ive hard coded it to 35. This works! However, when I pass in the response variable (which definitely contains 35) it can't find the element id. How is this possible? Hard coding works, passing the variable doesn't. They both contain the same value!!!! PS. I know that response definitely contains 35 as I have done the following to debug... alert(response); Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 5, 2007 Share Posted September 5, 2007 Is it set at that point in the code? I'm not sure what that other code is....isn't it javascript? Where is the code which tells the Javascript what value to put there? Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 5, 2007 Share Posted September 5, 2007 Have you looked at the source code to see what it literally sets the id to? See if it is what you want it to be. Quote Link to comment Share on other sites More sharing options...
ozzie135 Posted September 5, 2007 Author Share Posted September 5, 2007 Yeah it's an ajax response. It seems that the variable was of an incorrect type perhaps. The reason I think this is because I have changed the following: var response = xmlHttp.responseText; hideElement(resp); to var response = xmlHttp.responseText; var resp = parseInt(response); hideElement(resp); This has worked and resolves the issue. It seems that the variable was being changed in the ajax call....I THINK! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.