- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hello.
i need to add one of my dropbox to a widget, can i do this in html? Where i get the dropbox from backend and display it in the widget?
dropbox name u_choice_3
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi @asd22 ,
Create a new widget and add the code below-
Server script-
(function() {
// Example: get choices from a Choice table or custom logic
var choices = [];
var gr = new GlideRecord('sys_choice');
gr.addQuery('name', 'your_table_name'); // specify table if using choices
gr.addQuery('element', 'u_choice_3'); // field name for the choice field
gr.query();
while (gr.next()) {
choices.push({
label: gr.label.toString(),
value: gr.value.toString()
});
}
data.choices = choices;
})();
Client script-
function($scope) {
$scope.selectedChoice = '';
$scope.onChoiceChange = function() {
console.log("Selected choice:", $scope.selectedChoice);
};
}
HTML Code-
<div>
<label for="u_choice_3">Choose an option:</label>
<select id="u_choice_3"
ng-model="selectedChoice"
ng-options="c.value as c.label for c in data.choices"
ng-change="onChoiceChange()">
<option value="">-- Select --</option>
</select>
</div>
If you found my response helpful, please mark it as helpful and accept it as the solution.
Thank you
Nawal Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi @asd22 ,
Create a new widget and add the code below-
Server script-
(function() {
// Example: get choices from a Choice table or custom logic
var choices = [];
var gr = new GlideRecord('sys_choice');
gr.addQuery('name', 'your_table_name'); // specify table if using choices
gr.addQuery('element', 'u_choice_3'); // field name for the choice field
gr.query();
while (gr.next()) {
choices.push({
label: gr.label.toString(),
value: gr.value.toString()
});
}
data.choices = choices;
})();
Client script-
function($scope) {
$scope.selectedChoice = '';
$scope.onChoiceChange = function() {
console.log("Selected choice:", $scope.selectedChoice);
};
}
HTML Code-
<div>
<label for="u_choice_3">Choose an option:</label>
<select id="u_choice_3"
ng-model="selectedChoice"
ng-options="c.value as c.label for c in data.choices"
ng-change="onChoiceChange()">
<option value="">-- Select --</option>
</select>
</div>
If you found my response helpful, please mark it as helpful and accept it as the solution.
Thank you
Nawal Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hello this did not work, it did not get the dropbox thats already made, it just made a new dropbox
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi @asd22 ,
can you please share what you have already done so far and where you are stuck.so I can assist further. please share screenshot .
