Add Blank to Select

On my lightbox form I use lists populated from my db for selecting options.

On my scheduler page:

scheduler.config.lightbox.sections=[		
		{name:"promos", height:20, type:"select", map_to:"promo_ID", options:scheduler.serverList("promos")},
		]

On my php page:

	$list = new OptionsConnector($res);
	$list->render_sql("SELECT ID AS value, CONCAT(Type, ' ',Date) AS label FROM promos ORDER BY Date DESC","ID","value, label");
	$scheduler->set_options("promos", $list);

This assumes that there will always be a value associated with promos.

How can I add a blank default line to the top of the select listbox to hold a null value if nothing needs to be assigned to the promos listbox?

Thanks.

On server side, you can set the list of options, not by SQL, but by providing array of values - in such case you will be able to define any set of options.

docs.dhtmlx.com/doku.php?id=dhtm … ns_in_grid

So does that mean that I can either fill the listbox with a list from my db OR handcode the listbox items? Can I dynamically fill the list box AND just handcode a blank row? Thanks.

Hello,

I believe what Stanislav meant was that you can execute your own query to the database to get list of options, make array of the result, add blank value and then use it with set_options method.

Best regards,
Ilya

Thanks…

For some reason I cannot make progress on this, but I am not giving up… anyway you can provide an example?

Thank you.

Hello
I have major problem with recurring scheduler. I have different different tutor which have store his own free schedule and student can see and book the schedule.
But there is problem with how to add new data base table to store event_id and and tutor_id
and also add recuring table add filed.

Thanks in advance

Hi, manish4377

Please post your question in the separate topic.

Best regards,
Ilya

Hello, Chris.

Here’s a sample:

[code]<?php
include (‘…/…/…/codebase/connector/scheduler_connector.php’);
include (‘…/…/common/config.php’);

$res=mysql_connect($server, $user, $pass);
mysql_select_db($db_name);

$types_query = "SELECT typeid as value, CONCAT(typeid, ': ', name) as label FROM types";
$result = mysql_query($types_query);
$types = array("" => "Select option...");
if($result){
    while ($row = mysql_fetch_assoc($result)){
        $types[$row['value']] = $row['label'];
    }
}

$scheduler = new schedulerConnector($res);
//$scheduler->enable_log("log.txt",true);
$scheduler->set_options("type", $types);
$scheduler->render_table("tevents","event_id","start_date,end_date,event_name,type");

?>[/code]
While working on it found bug in base_connector.php so thank you very much for question :slight_smile:
I’ve attached updated file.

Best regards,
Ilya
base_connector.zip (5.36 KB)

Thank you very much.

I adapted your code, and I am going to learn more on arrays.

I’m glad I helped you indirectly as you’ve been helping me so much.

I have to post one more question in the forum, and I’ll be good to go for a bit I feel.

Can a similar concept be implemented for dhtmlx form with options connector?
Need to add a blank as well within select

$options = new SelectOptionsConnector($conn);
$options->render_sql(“SELECT id,name from $mytbl WHERE age=‘18’ “,””,“nodeId,nodeName”);

Thanks

why not use:

$options->render_sql(“SELECT ‘0’ AS id, ‘’ AS name from dual UNION SELECT id,name from $mytbl WHERE age=‘18’ “,””,“nodeId,nodeName”);

For SelectOptionsConnector - it will be more simple just output necessary xml structure directly.

echo "<data>"; if($result){ while ($row = mysql_fetch_assoc($result)){ echo "<option>".$row["label"]."</option>"; } } echo "</data>";