The selected items in the Combobox are displaying as [object, Object] instead of their actual String values

Below is the code I have for a ComboBox with a checklist:

<sq8:ComboBox runat="server" ID="ComboBox1" CheckBoxes="True" CheckedItemsTexts="DisplayAllInInput" Width="340px" OnClientItemChecked="ShowAlert"><Items>
      <sq8:ComboBoxItem runat="server" Value="Yes" Text="Yes"></sq8:ComboBoxItem>
      <sq8:ComboBoxItem runat="server" Value="No" Text="No"></sq8:ComboBoxItem>
      <sq8:ComboBoxItem runat="server" Value="Maybe" Text="Maybe"></sq8:ComboBoxItem>
      </Items>
    </sq8:ComboBox>
    <sq:BindableControl runat="server" TargetControlID="ComboBox1" DataField="ComboBox1"></sq:BindableControl>

This is the JavaScript function I am using to display the checked items in an alert:

<script type="text/javascript>

function ShowAlert() {

var combobox = $findByControlId("ComboBox1").get_checkedItems();


alert(combobox);


}

</script>

When I test this, the alert displays the values as:

[object Object]

I attempted to fix this by adding ".ToString" at the end of the alert:

alert(combobox.ToString);

However, this changed the checked items to "undefined" rather than displaying "[object Object]". I am unsure what to do next. Could someone provide assistance? The datatype for the ComboBox in my data model is String. Do I need to change it?

Thank you!

Answer №1

Experiment with this code snippet: let dropdown = $findElementById("DropDownMenu1").selectedItems.text());

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Setting up instagram-node-lib for managing subscriptions

I am currently working on implementing real-time updates for a specific hashtag and displaying the image on the screen. However, I am facing issues setting up my node.js server using the instagram-node-lib module. Even after running the file (node server.j ...

What is the method for including the sources directory within the require() scope in npm?

Upon examining my directory structure, the following layout is revealed: package.json /src a.js /test test_a.js The contents of package.json are as follows: { "name": "foo", "scripts": { "test": "mocha" }, "devDependencies": { "mocha ...

Utilizing jQuery to enable a div to follow the touchmove or mousemove events while also automatically

I am looking to create a basic function in my jQuery script. I want the pages to slide horizontally in response to the movement of a finger or cursor on the screen. While there are many plugins available for this purpose, I prefer a simple, customized solu ...

Is there a way to set the AutoComplete control in Material-UI as mandatory?

Yesterday was a frustrating day as I attempted to set the AutoComplete control as required. Unfortunately, the API lacks a required attribute and onNewRequest doesn't trigger if the textbox is empty. Additionally, onBlur has a glitch preventing it fro ...

The application is functional, however, the initial controller within is experiencing difficulties

Setting up a controller in my application based on a tutorial. The first two divs are displaying correctly but the ContraAss controller is not rendering and only shows {{info}}. What am I missing here? (NB. Probably something simple, but with limited exper ...

Upon receiving AJAX-content, the next iteration of the $.each function will be triggered

This question has been asked on an online forum in the past, but it was around four years ago and there may be a more efficient solution available now. In my code, I have a loop that sometimes requires additional data to be fetched through ajax calls. Af ...

Displaying a Vue.js component only when a specific API condition is satisfied: A step-by-step guide

After experimenting with v-if, I encountered the following error: Uncaught TypeError: Cannot read property '0' of undefined I have identified the issue to be related to the fact that the code cannot execute without the data being fetched first. ...

Using forEach to iterate through objects presents challenges when attempting to make changes

What is the reason behind the success of the first modification (when reassigning properties of the object) but the failure of the second modification (when reassigning the whole object)? const arr1 = [ { id: 1, value: 1 }, { id: 2, value: 2 }, ...

Class methods cannot be invoked within their constructor

I'm currently facing challenges with implementing my express router. This is a "subrouter" of my main router, hence I need to extend express.Router. Here's an example of the code (simplified to include only one method): import express from "expr ...

Paper.js: Is there a way to prevent canvas height and width from changing when the window is resized?

My canvas with paperjs is set up to resize dynamically when the window is resized. I appreciate any help in advance. HTML <canvas id="myCanvas" height="800" width="1000"></canvas> JS var Initialize = function () { var canvas = document ...

Using scriptlet based IDs in jQuery selectors involves incorporating JavaScript syntax within the jQuery selector to

I need to incorporate dynamic ids in my form, which are based on jsp variables within a scriptlet. How do I correctly select the desired element using jQuery's id selector without encountering any errors? Below is the code snippet: <form name="in ...

Can you clarify the distinction between calling subscription.unsubscribe() and subscription.remove()?

Currently, I am working with Angular 5 and have successfully subscribed to an observable with the use of the subscribe() method. My concern pertains to whether simply calling the unsubscribe() method on the subscription will be adequate for cleaning up all ...

What are the most efficient methods for implementing a deep level update in a React Redux store?

Currently experimenting with Redux and constructing an application driven by dummy data. Within my application, there exists a component labeled "birdInfo" which holds some state within the Redux store. https://i.sstatic.net/Msdu5.png To update the store ...

Fetching Dependencies with NPM from the package.json file

I am feeling a bit puzzled. While working on my laptop, dependencies were automatically added to my package.json file as I installed them for my project. This is how it appears: "main": "webpack.config.js", "dependencies": { "immutable": "^3.7.6", ...

Upload the PDF file along with other form data in a React application

I'm currently facing an issue with using formData for submitting a pdf file const [file,setFile] = useState() const [isFilePicked, setIsFilePicked] = useState(false); I have an input of type file <input accept=".pdf" type="file&quo ...

Unlocking the potential of Vue within shadow dom environments

I am facing an issue with a shadow DOM that includes the root element and a Vue component. <template> <div class="container"> <div id="app"></div> </div> <script src="http://my-site.com/app/js/vue-compo ...

Having trouble with publishing to npm as public with the --access flag not functioning properly?

When trying to publish a fresh scoped package on NPM using the command npm publish --access public, I encountered the following error: ole@mki:~/cli$ npm publish --access public npm ERR! publish Failed PUT 403 npm ERR! code E403 npm ERR! F ...

Searching in real-time with ajax in CodeIgniter framework is a seamless and efficient process

I'm a beginner in CodeIgniter and eager to learn. Currently, I'm facing an issue where the data is not being populated on the search page. In the model: function fetch_data($query) { $this->db->select('*'); $this-> ...

I am confused as to why my account within the administrators group is unable to access an asp.net page even though I have specifically granted access to

I have a straightforward question. On Windows 7, I have an account named "saqib" that is part of the "Administrators" group. My goal is to allow "saqib" to access an admin page in my asp.net application. To achieve this, I have enabled windows authenticati ...

What steps can I take to make sure a particular node is successfully loaded and ready for use using JavaScript/jQuery?

When making a reservation at a hotel using the CJS Chrome extension, I am attempting to extract information about available rooms and rates both when the page loads and when the user changes dates. My current method involves injecting JavaScript into the p ...