[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
www.dhtmlgoodies.com • View topic - Chained Select Boxes error
Advertisement

Chained Select Boxes error

Moderators: Calcifer, slothy

Chained Select Boxes error

Postby Minute » Wed Dec 13, 2006 5:13 am

Hi guys, am new with ajax and need some help. I followed the Chained Select Boxes tutorial (basically copied the code) and tried using it. Whenever I select a country from the country select box, I get the following error "Syntax Error on Line 72. I am using the cakephp for this. Any help will be greatly appreciated. Thanks in advance!

Below is my code:

<HEAD>
<style type="text/css">
body{
background-repeat:no-repeat;
font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif;
height:100%;
background-color: #FFF;
margin:0px;
padding:0px;
}
select{
width:150px;
}
</style>
<script type="text/javascript" src="C:/www/cake/app/webroot/js/ajax.js"></script>
<script type="text/javascript">
/************************************************************************************************************
Ajax chained select
Copyright (C) 2006 DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com


************************************************************************************************************/
var ajax = new sack();

function getCityList(sel)
{
var countryCode = sel.options[sel.selectedIndex].value;
document.getElementById('dhtmlgoodies_city').options.length = 0; // Empty city select box
if(countryCode.length>0){
ajax.requestFile = 'getCities.php?countryCode='+countryCode; // Specifying which file to get
ajax.onCompletion = createCities; // Specify function that will be executed after file has been found
ajax.runAJAX(); // Execute AJAX function
}
}

function createCities()
{
var obj = document.getElementById('dhtmlgoodies_city');
eval(ajax.response); // Executing the response from Ajax as Javascript code
}


</script>
</HEAD>
<BODY>
<form action="" method="post">
<table>
<tr>
<td>Country: </td>
<td><select id="dhtmlgoodies_country" name="dhtmlgoodies_country" onchange="getCityList(this)">
<option value="">Select</option>
<option value="dk">Denmark</option>
<option value="no">Norway</option>
<option value="us">US</option>
</select>
</td>
</tr>
<tr>
<td>City: </td>
<td><select id="dhtmlgoodies_city" name="dhtmlgoodies_city">

</select>
</td>
</tr>
</table>
</form>
</BODY>
Minute
 
Posts: 2
Joined: Wed Dec 13, 2006 5:05 am

Postby Batalf » Wed Dec 13, 2006 9:59 am

Batalf
Site Admin
 
Posts: 2160
Joined: Sat Oct 22, 2005 9:38 pm

Postby Minute » Thu Dec 14, 2006 1:57 am

Hi Batalf!

Thanks for the reply. I added the alert message and the output I got was a whole HTML document. Its looking for a getCities function in the controller instead of the getCities.php. Any idea how I can fix this?

Here is the output from the alert

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>CakePHP : Missing Method in Controller</title>

<link rel="icon" href="/favicon.ico" type="image/x-icon" />

<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />

<link rel="stylesheet" type="text/css" href="/css/cake.generic.css" /></head>

<body>

<div id="container">

<div id="header">

<h1><FONT size = 6 Color = 'darkblue'></FONT></h1>

</div>

<div id="content">


<h1>Missing Method in InventoriesController</h1>

<p class="error">You are seeing this error because the action <em>getCities.php</em>
is not defined in controller <em>InventoriesController</em>
</p>


<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <strong>app/views/errors/missing_action.thtml</strong>
view file, a user-customizable error page for handling invalid action dispatches.</span>
</p>

<p>
<strong>Fatal</strong>: Create Method:
</p>
<p>&lt;?php<br />
&nbsp;&nbsp;&nbsp;&nbsp;class InventoriesController extends AppController<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function getCities.php()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br /><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
?&gt;<br />
</p>
<p>
in file : app\controllers\inventories_controller.php</p>

<p>
<strong>Error</strong>: Unable to execute action <em>getCities.php</em> in
<em>InventoriesController</em>
</p> </div>

<div id="footer">

&nbsp;

<a href="http://www.cakephp.org/" target="_new">

<img src="/img/cake.power.png" alt="CakePHP : Rapid Development Framework" border="0" /> </a>

</div>

</div>

</body>
Minute
 
Posts: 2
Joined: Wed Dec 13, 2006 5:05 am


Return to General questions regarding AJAX scripts

Who is online

Users browsing this forum: No registered users and 30 guests

cron