How would I delete the current selected drop-down row in reactJS?

I have a select row where data gets added when an input is entered. <Input … Read more How would I delete the current selected drop-down row in reactJS?

I have a select row where data gets added when an input is entered.

<Input type="select" name="selectProf" id="selectProf">
        <option>-</option>
        {
           thanks.map((t,i) =>
           <option key={i}>{t}</option> )
        }
</Input>

But when the specific option is selected I would like it to delete the specific row rather than the whole data in select.

My previous code was this:

function handleDelete(){
        localStorage.setItem('profileID', '[]')
}

But this cleared the array and in result deleted everything in the select.
I tried this:

    function handleDelete(){
        if (JSON.parse(localStorage.getItem('profileID')) === document.getElementById('selectProf').value){
            //code here
        }
    }

However this method did not work as it is incorrect. How would I go abouts deleting the specific select row?

Source: JavaSript – Stack Overflow



Leave a Reply

Your email address will not be published. Required fields are marked *