Hello, I am a novice, ask a question,I want to use “dhx.alert()” method to alert the combo’s value,How can I get the value of the combo?
//......more code......
{
type: 'combo',
id: 'designer',
name: 'designer',
label: 'Designer',
labelAlign: 'left',
labelWidth: 100,
value: '2',
width: 300,
align: 'left',
datatype: 'json',
url: '${pageContext.request.contextPath}/json/get_designer.htm',
sameLine: '',
select: true,
scroll: true
}
//......more code......
dhx.alert( $$('myform').getValues().designer )
where myform - id of form or toolbar object, in which combo element was created
I just tried this unsuccessfully. For the most part, the combo works great, but I can’t retrieve the value. The standard means of document.getElementById(‘comboName’).value returns nothing, nor does $(‘comboName’).value when using jQuery. Is there a simple means that doesn’t rely on Forms? I also tried your getSelectedValue() function, but that doesn’t seem to work either. My code is posted below, please help:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Initialization</title>
<link rel="stylesheet" href="combostyle.css" type="text/css" media="screen" />
</head>
<script>
window.dhx_globalImgPath="codebase/imgs/";
</script>
<link rel="STYLESHEET" type="text/css" href="codebase/dhtmlxcombo.css">
<script src="codebase/dhtmlxcommon.js"></script>
<script src="codebase/dhtmlxcombo.js"></script>
<script src="j/jquery-1.5.1.js"></script>
<body>
<h3>From select box</h3>
<select style='width:200px;' id="combo_zone1" name="alfa1">
<option value="1">a00</option>
<option value="2">a01</option>
<option value="3">a02</option>
<option value="4">a10</option>
<option value="5">a11</option>
<option value="6">a12</option>
</select>
<br>
<input type="button" onclick="javascript:testValue()" value="CLICK ME">
<br>
<script>
var z=dhtmlXComboFromSelect("combo_zone1");
function testValue() {
alert(" .... ??? ... " + $('combo_zone1').getSelectedValue());
}
</script>
</body>
</html>
Never mind, it has been solved. Thanks.