How to remove the selected option in select tag? - reactjs

I want to create a dropdown in such a way that on click of a button new dropdown is created but it should not show the selected option of the previous dropdown. I am able to create the dropdowns on button click but I can't figure out how to not show selected options of previous dropdowns.

Simply create an Array and map all your dropdowns from that. And in onClick function of button simply pop or modify the array element. I hope you got it. Feel feel to ask doubts and for more please update the source code.

Related

setState with radio buttons

Hi every one hope you're doing good,
I'd like to update my state with radio buttons that I generate dynamicaly.
my state is an array of objects, each object contains one question and 2 or more answer options,
each answer option is a radio button and by clicking it it will update one of the properties of the object.
I'm putting a link to get to the code, you'll be able to make changes and test them (but would not be saved)
I'll really appreciate you're help, thanks
https://scrimba.com/scrim/co9a8447a82665e7746ff8dcc

How to access click event of option in React dual list box?

I am using react-dual-listbox. Here I am able to select the columns and deselect and use the selected values. But, I want to access the selected option in selected items on click of that particular item.
Ex: if 2 options are selected. If i click on second one, It should give me the value and index of the selected option. I saw something to use selectedRef for that purpose, But I am new to React.
Could anyone please help me out.
<DualListBox
canFilter
preserveSelectOrder
options={this.state.availableColumns}
selected={selectedColumns}
onClick={this.selectedRef}
onChange={this.onColumnSelected}
/>

Angular Ng repeat with checkboxes - uncheck a particular checkbox from a button click

I have a list of checkboxes - that populate a tag textarea - when the user remove a tag I also want to uncheck the checkbox
When the user navigates away and come back the checkboxes should maintain the state they were in - ie check against the tags and see if they match
So I need
Click state to pouplate tags
initial check to see if the checkbox should be checked or not - the scope of the checkboxes is killed by navigating away unless I rootScope it maybe?
Delete tag unchecks the check box
Only 5 checkboxes in a list can be checked the 6th would return no.
Needs to be a select all with above taken into account
I am really quite lost in how to architect this at the moment
going from click to change to model to checked....
many thanks for any help
try to do the next thing - create an object { clicked : true, label: label}
when you goes throught ng-repeat you have an object to render and state, when somebody delete label - you should just add whole object to handler and there change checkbox state tie to needed element.
P.S. If you add some code we can work with your stuff.

Access highlighted item in AngularJS dropdown list

I'm generating a dropdown list like this:
<select ng-model="myModel.someName" ng-options="item.name as item.value for item in dropdownListOptions" ></select>
This works fine but now I'd like to be able to show some more information about each item in the list as the user moves up and down it, before they click on one to select it.
In other words I need to get the value of the currently highlighted option that the mouse is over without it being clicked on.
This is not something you can get with plain Javascript and you won't do better with Angular. There is no mouse over event for option elements of a drop down list.
The only way to achieve this is to have a custom drop down list made of HTML elements to which you will attach event handlers.
You can use Bootstrap CSS for example.

Apex radio button check from controller

I have a scenario and i ma getting no where:
I am having 20 record and i m using pagination via standartcontroller and my page size is 1.
one by one record are displayed on the screen and i am having a list or radio button to select options.
When user select a radio button i am getting its value and fill a map with record,value for some processing.
What i want to do is that when a user hits back button the option he has selected in radio button must be visible there. But its not coz every time i m filling new values in the radiobutton list so old values are not sustained.
What i want is when user hits back button he should be able to see the old radio button selected.
How can i achive this:
1.Is there any way to make a radio button list's values be checked through controller.
2.Do I need to use wrapperclass to do this.
Help needed.! Thanks
It will be easier to put this field into object. If you don't have such field in you sObject than I would suggest to create wrapper class in your controller and display list of this wrappers instead of your native sObject.
If your radio button field is already part of the object, then there's no need for a wrapper class, but if the radio button doesn't need to be part of the object then use a wrapper class to keep the object simple.
Check out this example of a wrapper class with check boxes.
Wrapper classes don't have to be complex.

Resources