Today, the development of the Web site encountered a small problem, how to dynamically through JS to select the selected control check the specified value. During debugging, the problem of Amazeui this UI component was discovered, and the style of its components could not be set to be selected by Selected=true.
Later, went to the official website to find the relevant methods to achieve, but in accordance with the official website of the code can not reach the selected effect, and finally can only remove the style, using the original HTML style, manually through JS to achieve this function.
Solutions
Manually through the native JS to achieve:
/**
* Set the Select control
to select the ID value of the * @param selectid SELECT *
@param checkvalue Select the value of option
* @author standard brother
* * function set_select_checked (Selectid, CheckValue) {
var select = document.getElementById (Selectid);
for (var i = 0; i < select.options.length i++) {
if (Select.options[i].value = = CheckValue) {
select.options[i ].selected = true;
break;
}}}
And then call it by:
Set Select to select the team
set_select_checked (' Edit-group ', group_id);
Note: Do not pass ' #edit-group ', accustomed to jquery, there will be problems ~
The problem is simple, but write it down and copy it directly next time.
Article Source: http://tech.yunyingxbs.com/article/detail/id/343.html