let's say with the select option(dropdown) on the visualforce page I have INDIA, USA, UK. if I select INDIA that should be displayed in visual force page and if I open again dropdown the selected value or displayed value on visualforce page, it should not display INDIA, it should display the only USA and the UK
Asked
Active
Viewed 507 times
1 Answers
0
You could do that using javascript in your visualforce page.
you need to include a js file like this:
<apex:includeScript value="{!$Resource.MyJavascriptFile}"/>
Store the values as options like this:
Options = [
{ label: '1', value: '1' },
{ label: '2', value: '2' },
{ label: '3', value: '3' },
{ label: '4', value: '4' },
];
Then your code need to detect a selected option you could do this like this:
var options = document.getElementsByName('{!$Component.foo}')
for(option in options)
if(options[option].selected)
alert('The selected value is: ' + options[option].value)
Once a value is selected you need to deleted from the option array like this:
let Selectedvalue = 3
let arr = [1, 2, 3, 4, 5, 3]
arr = arr.filter(item => item !== value)

Jojosfdc
- 101
- 1