View Full Version : Ajax included pages and forms/DOM commands

Jul 27th, 2007, 10:30 PM
I don't have any code to post here, so i'll try my best to describe what I need to know and maybe make up a small piece of code to decribe it.

When using Ajax to include a php page that has information from a database, the Ajax will return the outputted result onto the main page.

What i mean basically is, I have my main page 'index.php' and I have a form on the page:

<form method="post" name="myForm" action="">
<input type="text" name="first_name" value="" />
<input type="text" name="last_name" value="" />
<div id="search_response"></div>
<input type="submit" name="submit" value="Submit" />

and when the user types in a first name, Ajax will run onkeyup() and it returns some code from the PHP page that Ajax (lets just call it: otherPage.php), and the code on this page is something like this:

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<?php $j=0; do { $j++; ?>
<td><?php echo $row_QueryExample['FIRST_NAME']; ?></td>
<td><?php echo $row_QueryExample['LAST_NAME']; ?></td>
<td><input type="checkbox" name="assign<?php $j; ?>" value="Y" /></td>
<?php } while (blah blah); ?>

So, basically what this is all doing is it's a search, when as you type characters into first or last name, the search narrows down using Ajax.

Now, the problem that i'm having is when Ajax return the results into the '<div id="search_response"></div>' tags that I made, and say I click the checkbox 'assign' on some of the names, and submit the form, the page doesn't even recognize that there are any checkboxes in the window. I know this has to do with how javascript embeds things into the page, cause even in the source, it only shows '<div id="search_response"></div>' and not the included page.

I need to have access to the embedded page to see what the user has clicked for assign. (please keep in mind this isn't an actual working example, it's just what I used to explain the problem i'm having on a bigger scale.)

Is there anyway to acces the variable that are used or clicked in the form for the embedded Ajax page, cause it comeplete ignores that "<input>" field on the included page. Not even DOM commands and getElementById() can see the variables.

If I didn't make sense, let me know and i'll try and explain better. Hopefully someone understand the problem i'm having, and can help me. I appreciate any help. Thanks.

-- Drew