Reputation: 6353
I have two variables user
and group
declared. When I run the function removeGroupFromSite()
, it should alert me saying please select a group but the variable returns as null. I assume it's because it's getting the value of the select and not the selected option? How would I get the value of the selected option within these variables?
var user, group, strHTMLSiteUsers, strHTMLSiteGroups, strHTMLAvailable, strHTMLAssigned, arrOptionsAssigned, arrGroups, arrUsers, intOpts, booMatch, booErr;
$(document).ready(function(){
user = $('#my_SiteUsers');
group = $('#my_SiteGroups');
groupsAssigned = $("#my_SPGroupsAssigned");
groupAvailable = $("#my_SPGroupsAvailable");
userAssigned = $("#my_SPUsersAssigned").html("");
userAvailable = $("#my_SPUsersAvailable").html("");
$("button").click(function() { return false; });
populateUsers();
populateGroups();
});
function removeGroupFromSite(){
//check if default group selected
alert('cp'+group.val());
if(group.val() !== "default"){
var removeConfirm = confirm("Are you sure you want to delete group: " + group.val());
if(removeConfirm){
$().SPServices({
operation:"RemoveGroup",
groupName: group,
async:true,
completefunc: function (xData,Status){
alert(group + " succesfully deleted");
}
});
}
}else{
alert("Please select a group");
}
}
HTML
<select id="my_SiteGroups" style="width:200px;" onchange="RefreshUserLists()">
<option value='default' disabled="disabled">Select a group</option>
</select>
Upvotes: 0
Views: 66
Reputation: 54016
simple fix
remove disabled="disabled"
from <option>
disabled
property does not carry the value from DOM as it was disabled.
disabled
This Boolean attribute indicates that the form control is not available for interaction. In particular, the click event will not be dispatched on disabled controls. Also, a disabled control's value isn't submitted with the form. This attribute is ignored if the value of the type attribute is hidden.
Upvotes: 1