Jump to content

table dissapears


tallberg

Recommended Posts

Dear who ever can help?
I’m new to Ajax

The problem:

An (input type button) submit button on html page sends form data to javascript to the php.

The response from the php produces a table of db records with a while loop. One of the td’s in the table is a button with javascript to send a record id to another php script to insert the id into another table. Everything works fine. The problem is that when the button is pressed the table disappears. To retrieve the records the submit button has to be pressed again.

for($i=0; $i<$intCount; $i++)
{
echo "<tr><td>$simArray[$i]</td><td>$descriptionArray[$i]</td><td>$usageArray[$i]</td><td>$idArray[$i]</td><td><input type='button' name='add' value='add' onClick='javascript:sendList($idArray[$i]);' ></td><tr>";
}
echo "</table>";

This code is the response producing a table.  When the javascript is activated the table disappears?
Link to comment
Share on other sites

So you're trying to update the div from 2 seperate functions, right?  So the return value of the second function is going to update as it sees fit.  That's how you have set it up.

If that's not how you want it to work, I suggest the following:

1) use 2 different xmlhttprequest objects.
2) use 2 different <div>s to update status.

If I understand you correctly, that's what needs to happen.
Link to comment
Share on other sites

Sorry if i did'nt explain well.

It appears the problem is not just related to ajax. Id tryed just using php. The dissapearing table problem persists.

The button i am refering to is the one in the code below. When it is pressed all of the info in the arrays dissapears so the table disserpears.

This is why ive tryed ajax. I thought it would stop this problem.

for($i=0; $i<$intCount; $i++)
{
echo "<tr><td>$simArray[$i]</td><td>$descriptionArray[$i]</td><td>$usageArray[$i]</td><td>$idArray[$i]</td><td><input type='button' name='add' value='add' onClick='javascript:sendList($idArray[$i]);' ></td><tr>";
}
echo "</table>";
Link to comment
Share on other sites

Ive only uploaded part of the DB. For this example use group = shrubs or height = 140. Leave the rest of the feilds black.

http://www.tallberg.co.uk/plant_list/v5_working/plant_selector3.php

This version is made only with php and almost works. The $condition that go in the SELECT statement is now in a hidden feilds which get past back to the SELECT statement.

There are two problems with this related to pressing the add button. 1. it only works with numerical feilds. Because the $condition has may contain strings such as The_Group ='Alpines' so  the value attribute in the hidden input field of the condition can not pass it becasue of the additional commas. 2. Every time the add button is pressed the it has to once again retrieve all the data which is time consumming.

http://www.tallberg.co.uk/plant_list/v6_withAjax/plant_selector3.php

This version is made with ajax, but the problem of the dissapearing table persists. I suppose i could put a hidden feild in this one too (if i can sort out the comma's problem) but i was hoping to over come the problem of having to once again retreive all the records from the db. The add button works, In that it submit records into a table via ajax. But the table dissapears.

If you can help please think about it in terms of the ajax version becasue the php one looks abit shaky when the form is submited.



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.