Autofill dropdown Client not working

Hello, I’ve made a little 2 minutes video to show you what is my problem exactly. i need you to tell me what file you need me to copy and paste you so you can maybe know whats going wrong in my code.
Thank you very musch for your time and patience
Seby
simplestudiophoto.com/calendar/Calendar.html

Maybe this is one of the file you need to see.
tks
Seby


function init() {

///////////////////-------------added by sushma ////////////////

var sections=[
{key:‘Business’, label:“Business”},
{key:‘Quote’, label:“Quote”},
{key:‘Personal’, label:“Personal”}

];

scheduler.locale.labels.unit_tab = “Unit”
scheduler.locale.labels.section_custom=“Select”;
scheduler.config.details_on_create=true;
scheduler.config.details_on_dblclick=true;

scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.config.prevent_cache = true;

/////////////////////////////////////////////////////////////

scheduler.config.lightbox.sections=[
{name:“session”, height:20, map_to:“session_name”, type:“textarea” , focus:true},
{name:“type”, height:20, type:“select”, options:sections, map_to:“type” },
{name:“subtype”, height:20, type:“select”, map_to:“session_type”,options:scheduler.serverList(“session_type”) },
{name:“clients”, map_to:“client_id”, type:“combo”, image_path: “…/…/codebase/dhtmlxcombo/codebase/imgs/”, filtering: true, script_path: “php/complete.php”, cache: true },
{name:“place”, height:20, type:“textarea”, map_to:“session_location” },

{name:“time”, height:70, type:“calendar_time”, map_to:“auto”},

{name:“notes”, height:80, type:“textarea”, map_to:“session_notes” }

]
scheduler.config.first_hour=4;
scheduler.locale.labels.section_session=“Event Name”;
scheduler.locale.labels.section_notes=“Notes”;
scheduler.locale.labels.section_type=“Type”;
scheduler.locale.labels.section_subtype=“Sub Type”;
scheduler.locale.labels.section_place=“Place”;
scheduler.locale.labels.section_clients=“Clients”;

//top label of calendar
scheduler.templates.calendar_month = scheduler.date.date_to_str("%F %Y");
//week label of calendar
scheduler.templates.calendar_scale_date = scheduler.date.date_to_str("%D");
//date value on the event’s details form
scheduler.templates.calendar_time = scheduler.date.date_to_str("%d-%m-%Y");

scheduler.templates.event_class = function(s,e,ev){
if (ev.type == ‘Personal’) return “Personal”;
if (ev.type == ‘Business’) return “Business”;
if (ev.type == ‘Quote’) return “Quote”;
return “”;
}

//scheduler.locale.labels.section_radiotype=“Select”;
//scheduler.config.details_on_create=true;
//scheduler.config.details_on_dblclick=true;
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();

scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.init(‘scheduler_here’,new Date(curr_year,curr_month,1),“year”);
scheduler.setLoadMode(“year”);

scheduler.load(“php/events.php”);

var dp = new dataProcessor(“php/events.php”);
dp.init(scheduler);

}

And also here’s my complete.php, maybe that can help


<?php header("Content-type:text/xml"); ini_set('max_execution_time', 600); session_start(); include ('../../../codebase/connector/scheduler_connector.php'); include ('../../common/config.php'); print("<?xml version=\"1.0\"?>");
$link = mysql_pconnect($server, $user, $pass);
$db = mysql_select_db ($db_name);

if (!isset($_GET["pos"])) $_GET["pos"]=0;

getDataFromDB($_GET["mask"]);
mysql_close($link);



//print one level of the tree, based on parent_id
function getDataFromDB($mask){
	$sql = "SELECT DISTINCT full_name, id FROM clients Where user_id = '".$_SESSION['user_id']."' AND full_name like '".mysql_real_escape_string($mask)."%'";
	$sql.= " Order By full_name LIMIT ". $_GET["pos"].",20";

	if ( $_GET["pos"]==0)
		print("<complete>");
	else
		print("<complete add='true'>");
	$res = mysql_query ($sql);
	if($res){
		while($row=mysql_fetch_array($res)){
			print("<option value=\"".$row["id"]."\">");
			print($row["full_name"]);
			print("</option>");
		}
	}else{
		echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file<br>";
	}
	print("</complete>");
}

?>

And dbScript.php


<? function getDataFromDB($mask){ $sql = "SELECT DISTINCT full_name FROM clients Where full_name like '".mysql_real_escape_string($mask)."%'"; $sql.= " Order By full_name LIMIT ". $_GET["pos"].",20"; if ( $_GET["pos"]==0) print(""); else print(""); $res = mysql_query ($sql); if($res){ while($row=mysql_fetch_array($res)){ print(""); print($row["full_name"]); print(""); } }else{ echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file
"; } print(""); } ?>

Hi,
when lightbox is opened, combo sends request for currently selected option, you need to process it.
request: dbScript.php?id=selectedId the expected response:

[code]<?xml version='1.0' encoding='utf-8' ?>

[/code]

Hello Aliaksandr can you give me a little more details in what files I should put that or what is the way to accomplish it please?
tks
seby

Well, actually, where does the dbScript.php get called?
tks
seby

Well, actually, where does the dbScript.php get called?
Sorry I misread your post, combo never calls it. It calls complete.php, as specified in ‘script_path’;

Combo sends request to it’s ‘script_path’ in two different cases:

  • right after lightbox is opened and combo need to display selected item, request looks like following - “script_path?id=selectedId”
  • when user types something and combo performs autocomplete - “script_path?pos=position&mask=userInput”
    Currently you are processing only the second case

btw $sql = "SELECT DISTINCT full_name, id FROM clients Where user_id = '".$_SESSION['user_id']."' AND full_name like '".mysql_real_escape_string($mask)."%'"; $sql.= " Order By full_name LIMIT ". $_GET["pos"].",20";you should also escape $_GET[“pos”]

Ok, i think I do understand a little, but thing i’m not sure how to do, it to make the call for the reading of the database and where to put it. cause the autocomplete is working, but it’s the reading, when I re-open it" that does not show.
How to do that sir
Tks again
Seby

Hi again, my programmer ask me this question for you:

where is lightbox opening? and which script need to use call that datas

tks
Seby

Here is the code, i hope it clarifies the point.
if you update your complete.php with it, calendar should show seleted item when you re-open the details form. However I haven’t actually tested it, you may need to fix something
complete.php:[code]<?php
header(“Content-type:text/xml”);
ini_set(‘max_execution_time’, 600);
session_start();
include (’…/…/common/config.php’);

print("<?xml version=\"1.0\"?>");

$link = mysql_pconnect($server, $user, $pass);
$db = mysql_select_db ($db_name);

if (!isset($_GET[“pos”])) $_GET[“pos”]=0;

$data = null;

if(isset($_GET[“mask”]))
$data = getAutoCompleteData($_GET[“mask”]);
else if(isset($_GET[“id”]))
$data = getSelectedValue($_GET[“id”]);

if($data)
renderOutput($data);

mysql_close($link);

function getAutoCompleteData($mask){
$sql = “SELECT DISTINCT full_name, id FROM clients Where user_id = '”.$_SESSION[‘user_id’]."’ AND full_name like ‘".mysql_real_escape_string($mask)."%’";
$sql.= " Order By full_name LIMIT “. mysql_real_escape_string($_GET[“pos”]).”,20";
return mysql_query ($sql);
}
function getSelectedValue($id){
$sql = “SELECT full_name, id FROM clients Where user_id = '”.$_SESSION[‘user_id’]."’ AND id = ‘".mysql_real_escape_string($id)."’";
return mysql_query ($sql);
}

function renderOutput($sqlResult){
if ( $_GET[“pos”]==0)
print("");
else
print("");

if($sqlResult){
	while($row=mysql_fetch_array($sqlResult)){
		print("<option value=\"".$row["id"]."\">");
		print($row["full_name"]);
		print("</option>");
	}
}else{
	echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file<br>";
}
print("</complete>");

}[/code]

Hi, thank you very much for this. Ive copy and pasted it in my complete.php. I got no error on the calendar. The autocomplete is still working but not the reading. Too good to be true lol… But my programmer will have a look at it. And Ill give you news.

Hi again Sir, ok here’s what we came up with to help you find the problem.
simplestudiophoto.com/calendar2/Calendar2.html
tks
seby

Can you check requests sent from the page?
please do the following using Google Chrome

  1. open calendar page
  2. open developer tools(ctrl+shift+i by default)
  3. select “Network” tab
  4. select “XHR” requests only and press “Clear”(there are controls at the bottom of the panel)
  5. open some event, there should appear request like following:
    complete.php?id=105&uid=1362500078475
    is it there? if so, can you post the response?

Ok, here’s what you asked me to do in another video cause I have in Chrome another error since the new code you gave me:
www.simplestudiophoto.com/Calendar3/Calendar3.html
tks
Seby

Great, thanks for the video. For some reason response xml is incorrect(as the error says), so selected text wont be displayed in the combo.
Probably there is a whitespace or something before the first xml element. I’m not sure why is it happening and why then it works for autocomplete.

You may try removing closing php tags ?> from complete.php and config.php, if there are ones - if you accidently put a whitespace or line-break after the closing tag it would be rendered to the response and will break xml output. However it’s unlikely the reason, in that case it would break autocomplete too.

Anyway, you should check that response for a correct content-type and characters that may break xml.

Hi, ok, I’ve removed the tags in both files and still xml problems.
What do you mean by this:
“Anyway, you should check that response for a correct content-type and characters that may break xml.”
Or do you have by any chance a working example of autocomplete script with mtsql database?
tks
Seby

Ok look at what i’ve found sir… We are getting closer lol
tks again
www.simplestudiophoto.com/calendar4/calendar4.html
Seby

Have you checked this example from scheduler’s package?
samples/02_customization/18_combo_select_from_db.html

No, I did not look at it, but we are close now. Have you watched the little video #4?
www.simplestudiophoto.com/calendar4/calendar4.html
tks
Seby