Greeting to all , i want to use a jquery ajax plugin: "
auto populating select boxes" for a submit form of the mxdirectory modules.
i have upload the sql file and test it on the server out of xoops, it works correctly!
then i try to make this works on xoops,
1. i have place those html code to the modules html file,
2. upload the sql file that the plugin provided to xoops modules prefix.
3. in the templates theme.html, i have include the jquery.js and the select-chain.js file in the header
4.the select-chain.php file i have place it to root, theme templates, modules root , modules templates directory..
(because i don't know the script "url:select-chain.php" means where)
i have edited the php file but not working...
here r the orignal php code, like this:
Quote:
<?php
if (@$_REQUEST['ajax']) {
// connect to local database 'test' on localhost
$link = mysql_connect('localhost', 'root', '');
if ($link == false) trigger_error('Connect failed - ' . mysql_error(), E_USER_ERROR);
$connected = mysql_select_db('test', $link); if ($connected) { $results = mysql_query('select * from test.select_chain where category="' . strtolower(mysql_real_escape_string(strip_tags($_REQUEST['category']))) . '"');
$json = array(); while (is_resource($results) && $row = mysql_fetch_object($results)) {
$json[] = '"' . $row->label . '"'; }
echo '[' . implode(',', $json) . ']'; die(); // filthy exit, but does fine for our example. }
else
{ user_error("Failed to select the database"); } }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Select Chain</title>
<style type="text/css" media="screen">
<!--
BODY { margin: 10px; padding: 0; font: 1em "Trebuchet MS", verdana, arial, sans-serif; }
BODY { font-size: 100%; }
H1 { margin-bottom: 2px; font-family: Garamond, "Times New Roman", Times, Serif;}
DIV.selHolder { float: left; border: 3px solid #ccc; margin: 10px; padding: 5px;}
TEXTAREA { width: 80%;}
FIELDSET { border: 1px solid #ccc; padding: 1em; margin: 0; }
LEGEND { color: #ccc; font-size: 120%; }
INPUT, TEXTAREA { font-family: Arial, verdana; font-size: 125%; padding: 7px; border: 1px solid #999; }
LABEL { display: block; margin-top: 10px; }
IMG { margin: 5px; }
SELECT { margin: 10px; width: 200px; }
-->
</style>
<script src="/js/jquery.js" type="text/javascript"></script>
<script src="select-chain.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
<!--
$(function () {
var cat = $('#categorySelect');
var el = $('#elementSelect');
var attr = $('#attributeSelect');
el.selectChain({
target: attr,
url: 'select-chain.php',
data: { ajax: true, anotherval: "anotherAction" }
});
// note that we're assigning in reverse order
// to allow the chaining change trigger to work
cat.selectChain({
target: el,
url: 'select-chain.php',
data: { ajax: true }
}).trigger('change');
});
//-->
</script>
</head>
<body id="page">
<div id="doc">
<h1>Select Chain</h1>
<div class="selHolder">
<h2>Element Category</h2>
<select id="categorySelect" name="category" size="5">
<option>Forms</option>
<option>Scripts</option>
</select>
</div>
<div class="selHolder">
<h2>Element</h2>
<select id="elementSelect" name="category" size="5">
<option>[none selected]</option>
</select>
</div>
<div class="selHolder">
<h2>Attributes</h2>
<select id="attributeSelect" name="category" size="5">
<option>[none selected]</option>
</select>
</div>
</div>
</body>
</html>
and i have edited the php file to this:
Quote:
<?php
if (@$_REQUEST['ajax']) {
global $xoopsDB;
$results=$xoopsDB->query('select * from x620_xdir_select_chain where category="' . strtolower(mysql_real_escape_string(strip_tags($_REQUEST['category']))) . '"');
$json = array(); while (is_resource($results) && $row = $xoopsDB->fetch_object($results)) {
$json[] = '"' . $row->label . '"'; } echo '[' . implode(',', $json) . ']'; die();
}
?>
i have copy a part of html code to modules index.html file..
Quote:
<select id="categorySelect" name="category" size="5"> <option>Forms</option> <option>Scripts</option> </select>
<select id="elementSelect" name="category" size="5"> <option>[none selected]</option> </select>
<select id="attributeSelect" name="category" size="5"> <option>[none selected]</option> </select>
i have include the jquery script and the plugin script on the header of the theme.html, like this:
Quote:
<script type="text/javascript">
$(function ()
{ var cat = $('#categorySelect');
var el = $('#elementSelect');
var attr = $('#attributeSelect');
el.selectChain({ target: attr, url: 'select-chain.php', data: { ajax: true, anotherval: "anotherAction" } });
// note that we're assigning in reverse order
// to allow the chaining change trigger to work
cat.selectChain({ target: el, url: 'select-chain.php', data: { ajax: true } }).trigger('change'); });
</script>
i have place this php file in the root , theme, modules, modules theme directory....
coz i don't know the script file " url: " means where.....
by the way i don't know how to correct those php code to connect the xoops database correctly..
in fect i m not a coder...haha
sorry for my poor english..
and thx for helping!