<option value="5" >123 Main St.</option>
mydropdown.options[mydropdown.selectedIndex].value
myAWcombo.setItemValue(["7", "12", "19", "20"]);
myAWCombo.onCurrentItemChanged = function(i){
var value = this.getItemValue(i);
this.setControlValue(value);
var text = this.getItemText(i);
this.setControlText(text);
this.hidePopup();
var e = this.getContent("box/text").element();
if (AW.safari) {
e.innerHTML = text;
}
else {
e.value = text;
e.select();
}
e = null;
}
var value = this.getItemValue(i);
this.setControlValue(value);
myAWCombo.onCurrentItemChanged = function(i){
...
}
<?php
function combo_setup($dataset){
$result_text = '[';
$result_value = '[';
$num_rows = mysql_num_rows($dataset);
$i = 1;
while ($row = @mysql_fetch_array($dataset))
{
$result_text .= '"'.$row['param_value']." - ".$row['param_text'].'"';
$result_value .= '"'.$row['param_value'].'"';
if($i < $num_rows)
{
$result_text .= ',';
$result_value .= ',';
$i++;
}
}
echo 'comboText = '.$result_text.'];'."\n\t";
echo 'comboValue = '.$result_value.'];'."\n\t";
echo 'comboItems = '.$num_rows.';'."\n\t";
}
?>
var comboClientDistrict = new AW.UI.Combo;
comboClientDistrict.setId("comboClientDistrict");
comboClientDistrict.setControlText("");
comboClientDistrict.setPosition(651, 81);
comboClientDistrict.setSize(250, 20);
<?php
$dataset = mysql_query("Select town AS param_text, sign AS param_value From WAIS_okres");
combo_setup($dataset);
?>
comboClientDistrict.setItemText(comboText);
comboClientDistrict.setItemValue(comboValue);
comboClientDistrict.setItemCount(comboItems);
comboClientDistrict.getPopupTemplate().setStyle("width",comboClientDistrict.getStyle("width"));
comboClientDistrict.getPopupTemplate().setStyle("height",17*(comboClientDistrict.getItemCount()<10?comboClientDistrict.getItemCount():10));
comboClientDistrict.getContent("box/text").setAttribute("readonly", true);
comboClientDistrict.onControlEditStarted = function(){
this.getContent("box/text").element().contentEditable = false;
}
//Got from PHP script:
comboText = ["1 - first","2 - second","3 - third","4 - fourth"];
comboValue = ["1","2","3","4"];
comboItems = 4;
//Added to the object:
comboCompanyType.setItemText(comboText);
comboCompanyType.setItemValue(comboValue);
comboCompanyType.setItemCount(comboItems);
comboCompany.getSelectedItems() // = 1
comboCompany.getItemText(comboCompany.getSelectedItems()) // = 1 - First
comboCompany.getItemValue(comboCompany.getSelectedItems()) // = undefined !!!!
var obj = new AW.UI.Combo;
var comboText = ["1 - first","2 - second","3 - third","4 - fourth"];
var comboValue = ["1","2","3","4"];
var comboItems = 4;
obj.setItemText(comboText);
obj.setItemValue(comboValue);
obj.setItemCount(comboItems);
obj.setSelectedItems([1]);
alert(obj.getItemValue(obj.getSelectedItems()));
obj.onControlValidated = function(){
alert(this.getItemValue(this.getSelectedItems()));
}
document.write(obj);
This topic is archived.