1
laden0868
auto populating select boxes for submit form..
  • 2010/12/1 18:31

  • laden0868

  • Just popping in

  • Posts: 8

  • Since: 2010/9/8 1


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:

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"); } }

?>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



Select Chain








Select Chain



Element Category





Element





Attributes










and i have edited the php file to this:

Quote:


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:








i have include the jquery script and the plugin script on the header of the theme.html, like this:
Quote:





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!


2
laden0868
I want to use this ajax jquery plugin for a submit form, but don't know how to connect xoops..
  • 2010/12/2 7:04

  • laden0868

  • Just popping in

  • Posts: 8

  • Since: 2010/9/8 1


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 a topic on this thread

i m a beginner of xoops, and i m not a coder anyway..

that plugin have a php file that let us to connect the database,
the code is :
Quote:

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"); } }

?>




i have try to edit those code to this but not working..


Quote:


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();
}

?>



can anyone tell me how to connect the database correctly,
or is that xoops need to install some plugin for json and else??

thank you very much, and sorry to my poor english.....

3
ghia
Re: auto populating select boxes for submit form..
  • 2010/12/2 9:38

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


No use to open a new thread.
Keep your problem together.

Login

Who's Online

550 user(s) are online (96 user(s) are browsing Support Forums)


Members: 0


Guests: 550


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits