tallberg Posted November 20, 2006 Share Posted November 20, 2006 Dear who ever can help?I’m new to AjaxThe 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? Quote Link to comment Share on other sites More sharing options...
ober Posted November 20, 2006 Share Posted November 20, 2006 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. Quote Link to comment Share on other sites More sharing options...
tallberg Posted November 20, 2006 Author Share Posted November 20, 2006 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>"; Quote Link to comment Share on other sites More sharing options...
ober Posted November 20, 2006 Share Posted November 20, 2006 Do you have a live version we can view? Quote Link to comment Share on other sites More sharing options...
tallberg Posted November 21, 2006 Author Share Posted November 21, 2006 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.phpThis 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.phpThis 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. Quote Link to comment Share on other sites More sharing options...
tallberg Posted November 21, 2006 Author Share Posted November 21, 2006 I just managed to sort it out. The responce variable had the same name. So i was losing the responce variable for the table data. 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.