Wordpress with Multiple Select Dropdown List with Ajax

Place for comments, problems, questions, or any issue related to the JavaScript / PHP scripts from this site.
Toky
Posts: 5

Wordpress with Multiple Select Dropdown List with Ajax

Hello you all,
I want to use Multiple Select Dropdown List with ajax ( https://coursesweb.net/ajax/multiple-sel ... ist-ajax_t ), the whole thing is just perfect for me, but I couldn't make it work.
I follow all the step by changing only the name of table with the columns in the array variable, and updated the database's access information yet nothing is showing where the dropdown list is supposed to show.
I placed the .js and .php files in the root of my website (hosted with hostpapa), and placed created a post, containing the form (preceded by Select: ) with wordpress.
Using two plugins, one to insert script in the header, and another inserting/executing a php code in posts, I got nothing works.
Your help will be very appreciated.

Here are the only change I brought :

Code: Select all

$table = 'loter390_baiboly';
$ar_cols = array('testament', 'book', 'chapter', 'content');
Thanks in advance.

Admin Posts: 805
Hello
To display the first Select Dropdown list, you must add in page the value of the php variable: $re_html.

Code: Select all

Select: <?php echo $re_html; ?>
I not know how Wordpress works with other php and javascript codes.
If there is javascript error in page (maybe from other js script), the Multiple Select Dropdown List with ajax will not work.
You can check in console (with F12) to see if there is JS error.

Toky Posts: 5
I already put the

Code: Select all

<?php echo $re_html; ?>
in the page to display the html code generated from the php, and it shows nothing (sorry for not mentioning it before).

The error log says that there is an issue with the session_start() function because another php file (header.php) has already sent headers. So I don't know if that is the origin of the problem.
I tried to make the line

Code: Select all

if(!isset($_SESSION)) session_start();
a comment so the header.php will start the session instead, but it didn't solve the problem.
Very sorry for my ignorance.

Admin Posts: 805
I not know how to help you in this problem, but i try.
Add a : var_dump($re_html); to see what data is in that variable.
If that page is publicly on a web hosting, add here the page address so I can see its html and js code.

To see if the Multiple Select Dropdown List with Ajax script works, test it with the "test.php" page (from the archive with the script), with your mysql table.

Toky Posts: 5
I'll be back, but I'll try first to make the Bible.php an independant page, and see if that's gonna work. (for now I get 501 error when trying to access the page directly)
Peace!

Toky Posts: 5
Hello there,
I got some things to work but still, need help.
Here is the address:
loterana-malagasy.org/index.php/baiboly/

It is in Malagasy, but I think you can guess. :) it says select here the testament (dropdown : NT, OT), the second dropdown is for the books and the third for the chapter, and the last for the verses.
Here is what comes out after hitting the F12 key:

Code: Select all

<html><head>
<meta charset="utf-8">
<title>Baiboly Malagasy</title>
<script src="ajax_select.js" type="text/javascript"></script>
</head>
<body>
<form action="" method="post">
Jereo eto ny boky sy ny toko ho vakinao: 
<br> 
TTTV: <select name="TTTV" onchange="ajaxReq('book', this.value);"><option>- - -</option>
<option value="Taloha">Taloha</option>
<option value="Vaovao">Vaovao</option>
</select> 
<span id="slo_book"> </span>
<span id="slo_chapter"> </span>
<div id="slo_context"> </div>
<script type="text/javascript">var ar_cols = ["TTTV","book","chapter","context"]; var preid = "slo_";</script>
</form>
</body>
</html>
Thanks for being patient with me.
Toky

Admin Posts: 805
The problem is to the path to "ajax_select.js", rellative to page address.
If the JS file is directly in the root folder, try use this code to include the js file (start the path with "/"):

Code: Select all

<script src="/ajax_select.js" type="text/javascript"></script>
Or with the full path:

Code: Select all

<script src="http://your-domain/ajax_select.js" type="text/javascript"></script>
Also, change the path to the php file in the "ajax_select.js":

Code: Select all

var php_file = '/select_list.php';
Or:

Code: Select all

var php_file = 'http://your-domain/select_list.php';

Toky Posts: 5
Halelujah, it's working, I had to do many turn around by posting another customed page to contain the "select_list.php".
Thanks a lot for your precious help.
God bless you!

Similar Topics