I have a multi-page form that works fine in and of itself (pathfindertool.module). However, once a user clicks submit I want the page to display some records on the page. And it DOES display the records on the page, but NOT within the flow of the page. What I mean by that is, it just puts all the returned results in the top-left of the page in the browser window in and not in a tag in the #content area for example where content is supposed to go.
I tried to use javascript document.getelementbyid.innerhtml, calling that from my php and it just returns no results (well it returned them according to console but it didn't display them):
while ($row = $result->fetchAssoc()) {
echo '<script type="text/javascript">';
echo 'window.onload(';
echo 'document.getElementById("pathfinder-primary-form").innerHTML=';
echo '"<div>';
echo $row['title'];
echo '</div>");';
echo '</script>';
}
}
I also tried doing drupal_add_js inside my .module file and can't get that to work either. Granted my coding here is pretty kloogy:
drupal_add_js('document.getelementbyId("pathfinder-primary-form").innerHTML = "', 'inline');
$title = $row['title'];
drupal_add_js('document.getelementbyId("pathfinder-primary-form").innerHTML = "', 'inline');
Surely this must be one of the most common workflows ever. What's the best practice for displaying data from a database in Drupal so that it displays within a specific (ie. #main, or perhaps even the form container itself)?
Here's my pretty basic functioning code so far for displaying the results in my .module file:
if ($result) {
while ($row = $result->fetchAssoc()) {
$title = $row['title'];
echo '<p>' . $title. '</p>';
}
}
But of course it displays it in the top-left corner of the body in the browser window right above the Logo! O.O
What am I doing wrong and how can I fix it?