sondra
February 7, 2011, 10:22am
#1
Hi all.
I want to use dhtmlcombo in my custom form of dhtmxscheduler but I have a problem.
When I Save the event the combo value is empty.
This is my js code:
scheduler.showLightbox = function(id){
var ev = scheduler.getEvent(id);
scheduler.startLightbox(id, html("my_form") );
scheduler.config.details_on_dblclick=true;
scheduler.config.prevent_cache = true;
scheduler.config.show_loading=true;
scheduler.config.details_on_create = true;
var d2s = scheduler.date.date_to_str("%Y-%m-%d %H:%i");
html("category").value = ev.category||"";
}
function save_form() {
var ev = scheduler.getEvent(scheduler.getState().lightbox_id);
var s2d = scheduler.date.str_to_date("%Y-%m-%d %H:%i");
ev.category = html("category").value;
scheduler.endLightbox(true, html("my_form"));
}
// simple html code :
</head>
<body onload="init();">
<div id="my_form">
<td><div id='category' name="category" style="width:150px; height:30px;"></div></td>
<script language="JavaScript" type="text/javascript">
var z1 = new dhtmlXCombo("category", "category", 150);
z1.loadXML("php/category.php");
</script>
</div>
<input style="padding:0.6em 1em; text-decoration:none;" type="submit" name="save" value="Save" id="save" onclick="save_form();">
Can you help me ?
Thank you.
Sondra
Ilya
February 7, 2011, 4:12pm
#2
Hello,
Try changing
ev.category = html("category").value;
with
ev.category = z1.getSelectedValue();
Note that z1 should be global variable or simply within the scope of the save_form() function.
Best regards,
Ilya
sondra
February 7, 2011, 5:58pm
#3
Thank you.
But the post value is null.
Some suggestion ?
Sondra
Ilya
February 8, 2011, 10:37am
#4
Hello,
Have you selected anything from the list?
Also i missed yesterday:
html("category").value = ev.category||"";
is not a correct way to set value for the combo box, change it to
var index = z1.getIndexByValue(ev.category);
z1.selectOption(index);
Also you can check /scheduler/sources/ext/ext_editors.js file to see how we implemented dhtmlx combo for the default lightbox form, it may be of help.
scheduler.form_blocks['combo']={
Best regards,
Ilya
sondra
February 8, 2011, 12:51pm
#5
Hi Ilya, now work.
Thank you.
I have another question/problem for combo:
Now I want append value to combo url for my custom query for example:
var z1 = new dhtmlXCombo("category", "category", 150);
z1.loadXML("php/category.php?="+ev.operator+"");
I have this code:
In js code:
scheduler.startLightbox(id, html("my_form") );
html("operatore").value = ev.operator||""; //
var index = z1.getIndexByValue(ev.category); // combo
z1.selectOption(index);
}
function save_form() {
var ev = scheduler.getEvent(scheduler.getState().lightbox_id);
ev.operator = html("operator").value;
ev.category = z1.getSelectedValue(); // combo
scheduler.endLightbox(true, html("my_form"));
}[/code]
In html form:
[code]
<div id="my_form">
<input type="text" id="operator" name="operator"> // take correct value ev.operator
<div id='category' name="category" style="width:150px; height:30px;"></div>
<script language="JavaScript" type="text/javascript">
var z1 = new dhtmlXCombo("category", "category", 150);
z1.loadXML("php/category.php");
</script>
</div>
[/code]
I try to append :
[code]z1.loadXML("php/category.php?="+ev.operator+"");
but don’t take the value, the value ev.operator is empty.
Some suggestion ?
Thank you very much.
Sondra.
Ilya
February 8, 2011, 1:38pm
#6
Hello,
It’s not really clear where in the code you create your dhtmlx combo but most likely that place has nothing to do with event for which your custom lightbox is displayed. That is why ‘ev’ is undefined.
What can be done:
In your showLightbox function you need to clear all current options in the combo and load new ones.
// inside showLightbox function
...
if(ev.operator) {
z1.clearAll(true); // clear all (including current) values in the combo
z1.loadXML("php/category.php?operator="+ev.operator+"");
}
Best regards,
Ilya
sondra
February 9, 2011, 12:11pm
#7
Hello Ilya.
Thank you, work perfectly.
My last question is :
I want insert checkbox in custom form but I’m confused.
I try this :
//....... in start lightbox function .....
scheduler.startLightbox(id, html("my_form") );
html("presence").value = ev.presence||"";
// ........in save form function......
ev.presence = html("presence").value;
// ......in my_form........
<div id="my_form">
<input type="checkbox" id="presence" name="presence" value="1">
</div>
But don’t work.
Can you help me ?
Thank you very very much.
Sondra.
For checkbox it will be something like
[code]html(“presence”).checked = ev.presence == “1”;
// …in save form function…
ev.presence = html(“presence”).checked?1:0;
[/code]