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