Jump to content

Ajax Updater


atholon

Recommended Posts

OK dokey, here is my problem.

 

I have a script that I am enabling users to use a select box to select a category for a tutorial they will submit. Then they select certain categories certain results are displayed as sub categories then when they choose certain sub categories certain programs are displayed according to the sub category.

 

Anywho so I have this for the JS to watch for the initial change


      var internalCat = document.getElementById('internalCat');
      var externalCat = document.getElementById('externalCat');

      if( internalCat )
      {
        internalCat.sbname = "internalSubCatSelect";
        internalCat.result = "internalSubCat";
        internalCat.onchange = ToggleCatText;
      }
      if( externalCat )
      {
        externalCat.sbname="externalSubCatSelect";
        externalCat.result="externalSubCat";
        externalCat.onchange = ToggleCatText;
      }

Then when they are toggled the ToggleCatText function executes which uses an Ajax.Updater() to retrieve the results in the php file.

new Ajax.Updater(catView, '../tutorials/process/catView.php?view=' + display + '&selectBoxName=' + selectBoxName, {asynchronous:false});

Then it is supposed to pass back the results like this:

$parentCategory = $_REQUEST['view'];
$selectBoxName = $_REQUEST['selectBoxName'];
$html = '';
$html .= "<select id=\"$selectBoxName\" name=\"$selectBoxName\">";
$count = 1;
$query=mysql_query("SELECT title FROM subcategories WHERE parent = '{$parentCategory}' ORDER BY title ASC");

if( mysql_num_rows($query) > 0 )
{
while($result=mysql_fetch_array($query))
{

	if ($count == 1)
	{
    $html .= "<option value=\"{$result['title']}\" selected=\"{$result['title']}\">{$result['title']}</option> ";
	}
	else
	{
	$html .= "<option value=\"{$result['title']}\" >{$result['title']}</option> ";
	}

}

mysql_free_result($query);
}
else
{
}

$html .= "</select>";

echo $html;

 

Thing is for some reason when I try to use the

      var internalSubCatSelect = document.getElementById('internalSubCatSelect');
      var externalSubCatSelect = document.getElementById('externalSubCatSelect');

It won`t trigger anything using onchange.... any ideas?

Link to comment
https://forums.phpfreaks.com/topic/95128-ajax-updater/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.