本文介绍了如何使用Rest Api获取不同的值并绑定到html下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,


我正试图从下面的代码中获取不同的值。但我发现没有进一步的运气。


任何人都可以告诉我下面代码中的错误。

< body> 
< table>
< tr>
< td>标题值< / td>
< td>月值< / td>
< / tr>
< tr>
< td>
< select id =" drbprogrames"类= QUOT;选取[;>
< option selected =" selected">选择< / option>
< / select>
< / td>
< td>
< select id =" drbmonths"类= QUOT;选取[;>
< option selected =" selected">选择< / option>
< / select>
< / td>
< / tr>
< / table>
< script type =" text / javascript" src =" https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">< / script>
< script type =" text / javascript" SRC =" HTTPS://code.jquery.com/jquery-3.1.1.js">< /脚本>
< script>
SP.SOD.executeFunc('sp.js','SP.ClientContext',startfucntions);

函数startfucntions()
{
gettitleValues();
getMonthValues();
}



函数getMonthValues()
{

alert(&"Helo");
$ .ajax({
url:_spPageContextInfo.webAbsoluteUrl +&_ / _ api / web / lists / GetByTitle('Tabletop%20Sessions')/ items?$ Select = Month",
type :"GET",
标题:{
" accept":" application / json; odata = verbose",
},
success:function(data){
var result = data.d.results; //获取结果
var monthvalues = groupBy(items,'Title');
$('#drbprogrames')。append(monthvalues) ;
},
错误:函数(错误){
alert(JSON.stringify(error));

}
});

}
< / script>
解决方案




Dear All,

I am trying to get the distinct values from below code .But I find no luck to move further.

Can any one let me know what's wrong in my below code.

<body>
<table>
<tr>
 <td>Title Values</td>
 <td>Month Values </td>
 </tr>
 <tr>
 <td>
       <select id="drbprogrames" class="select">
		<option selected="selected">Select</option>
		</select>
    </td>
  <td>
     <select id="drbmonths" class="select">
     <option selected="selected">Select</option>
</select>
  </td>
</tr>
</table>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js "></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.js"></script>
<script>
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', startfucntions);

function startfucntions()
{
 gettitleValues();
 getMonthValues();
}



function getMonthValues()
{

alert("Helo");
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Tabletop%20Sessions')/items?$Select=Month",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function (data) {
var result  = data.d.results;  // Get the results
var monthvalues = groupBy(items,'Title');
$('#drbprogrames').append(monthvalues);
},
error: function (error) {
alert(JSON.stringify(error));

}
});

}
</script>
解决方案




这篇关于如何使用Rest Api获取不同的值并绑定到html下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 18:23