<script type="text/javascript" src="Scripts/SPAPI_Core.js"></script>
<script type="text/javascript" src="Scripts/SPAPI_Lists.js"></script>
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="Scripts/TADDScript.js"></script>
<form id="form1" runat="server">
<script type="text/javascript">
<!--
function getOptions(siteURL, element, selectedVal) {
// sitteURL - url of the web, e.g., '/viewnet/railgun'
// element - jQuery object for the select list field.
// list - Name of the list to provide values
// selectedVal- (Optional) Value to select after select list has been rebuilt. If not supplied it defaults to 0
if (!selectedVal) { var selectedVal = ""; }
// Clear existing <option> tags.
$("select[title='" + element + "']").empty();
//alert('Here is element; ' + element);
var durl = document.getElementById('<%=drop1Url.ClientID%>').value;
var toturl = siteURL + durl +"/view";
alert(toturl);
// return true;
var sElement;
if (selectedVal == "") {
sElement = "<option value='0' selected='selected'>(none)</option>";
//$(element).append("<option value='0' selected='selected'>(none)</option>");
} else {
sElement = "<option value='0' selected='selected'>(none)</option>";
//$(element).append("<option value='0'>(none)</option>");
}
alert("sElement is " + sElement);
// Get all OPTION values from list
var lists = new SPAPI_Lists(toturl)
var listCollection = lists.getListCollection();
if (listCollection.status == 200)
{
var optionData = new Array();
var items = listCollection.responseXML.getElementsByTagName('List');
alert('There are ' + items.length + ' lists in the site.');
for (var i = 0; i < items.length; i++) {
//alert(items[i].getAttribute('Title') + ' ' + items[i].getAttribute('ID'));
//optionData.push(items[i].getAttribute("Title") + ":" + items[i].getAttribute("ID"));
sElement += "<option value='" + items[i].getAttribute('ID') + "'>" + items[i].getAttribute('Title') + "</option>";
//$("select[title='" + element + "']").append("<option value='" + items[i].getAttribute('ID') + "'>" + items[i].getAttribute('Title') + "</option>");
}
alert(sElement);
$("select#" + element).change($("select#" + element).html(sElement));
// optionData.sort();
// for (var i=0; i < optionData.length; i++)
// {
//
// if (selectedVal == optionData[i].split(":")[0]) {
// $("select[title='" + element + "']").append("<option value='" + optionData[i].split(":")[1] + "' selected='selected'>" + optionData[i].split(":")[0] + "</option>");
// } else {
// $("select[title='" + element + "']").append("<option value='" + optionData[i].split(":")[1] + "'>" + optionData[i].split(":")[0] + "</option>");
// }
// }
alert("status is :" + listCollection.statusText);
}
else
{
alert('There was an error: ' + listCollection.statusText);
alert("status = " + listCollection.status);
}
}
//-->
</script>
|