Jump to content

A little DOM problem


scottybwoy

Recommended Posts

Hi programmers, web developers,

Not really sure if this shud be here but you may be able to help.  I have a home.php script that build my main page like so :
[code]
<?php
    function displayHome()
    {
    $content = $_REQUEST['content'];

    if($content == "")
    {
$content = "admin";
}

require_once(HEADER);

echo<<<END
<table width=100%>
<tr width=100% class="canvas">
<a class="butText" href="home.php?content=client">Client</a>
<a class="butText" href="home.php?content=sale">Sale</a>
<a class="butText" href="home.php?content=admin">Admin</a>
<a class="butText" href="home.php?content=report">Report</a>
<a class="butText" href="home.php?content=rma">RMA</a>
</tr></table>
<table width=100% valign="left"><tr>
<td rowspan="2" width=60%>
END;
include(TEMPLATE_DIR . "/$content.inc");
echo "</td><td width=40%>";
include(TEMPLATE_DIR . "/inform.php");
echo "</td></tr><tr><td>";
include(TEMPLATE_DIR . "/prodDisp.php");
echo "</td></tr><tr><td colspan='2'>";
  require_once(TEMPLATE_DIR . '/footer.php');
echo "</td></tr></table>";

}
?>
[/code]
And within my HEADER I have a little AJAX magic it includes two JavaScript files that I know it's finding as it sort of works.

Basically it is a dynamic Drop down list that works like Google Suggest except for Companies in the database.  So it captures the key click and sends it to a .php file in the same directory which queries the database and sends back the result.

I edited this file so that it didn't wait for a keyclick but used static data within the file and ran it from it's directory to see if it was working and it did.  So changed it back.

If I run the .html file itself it works fine, but if I run it throught my php script it doesn't bring up any data.  All directories remain the same.

Here's the html :
[code]
<td width=20%><input type="text" id="company" name="company" value="" onkeyup="ajax_showOptions(this,'getCountriesByLetters',event)"></td>
[/code]
Here's the .php :
[code]
<?php
if(isset($_GET['getCountriesByLetters']) && isset($_GET['letters']))
{
$letters = $_GET['letters'];
$letters = preg_replace("/[^a-z0-9 ]/si","",$letters);
$res = mssql_query("select custId, company from customers where company like '" . $letters . "%'") or die("Stupid database");
//echo "1###select custId, company from customers where company like '" . $letters . "%'|";
while($inf = mssql_fetch_array($res))
{
echo $inf["custId"] . "###" . $inf["company"] . "|";
}
}
?>
[/code]

Any Ideas?
Link to comment
Share on other sites

Ok sussed this one, where my javascript code had originally asked for the php file it now started its root from the php that created the page, for anyone else out there bamboozled by this little puzzle ;)

However now I get the Data into my Input box, what do I need to put on my button to send that data to php. Like my <a href> buttons do in the original post and also bring up the customers form with the data already filled in?

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.