Jump to content

Urgent help required please???


ozzie135

Recommended Posts

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.

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.