-5

I have an autogenerated select box (based on the user decisions in other fields). I am useing "onclick" event inside "onlick" event.

The plan:

  1. If the user click on this I have to disable some other fields and the select(dropdown menu) opens. The ideal would be if after the user's previous decision this select opens automaticly but looks like I can't open a select by JS, to make is work in every type of browser, so I have to make the user do it.

  2. At the secound click I would like to get the value what the user choose and do something with it. But the user may not choose it or missclick out from the select and may close it (It may mess up the enable/disable other fields). So I would like to force the user to click on a value if the select is already opened by the user.

Here is the code:

document.getElementById("infodropdown").onclick = (function() //the select opens + I disable other fields
{
  document.getElementById("infodropdown").onclick = (function() //the user should choose a value
  {
   //do something with the input, and enables other fields
  });
});

If there any other more advanced way to make the user select if he/she opens the dropdown very welcome. Thanks you very much for any suggestion!

Nefri
  • 197
  • 2
  • 13
  • 1
    First of all, if this is for a website then a dropdown like that is a horrible user experience. And if you want a user to click on something, just present them with a choice list before continuing to a new part of the website. – Mouser Oct 10 '17 at 14:50
  • why? what are you trying to do/build? 2nd. Clicking ain't the only way to change the value of a selectbox; don't focus too much on clicks. And don't annoy your users like that. If it is necessary to select a value to complete the task at hand, your users will do that; and if they don't want to, they'll leave. If you try to push your users like that, you're only shifting the chances towards leaving the page. – Thomas Oct 10 '17 at 14:55
  • It is a bit hard to explain. I have multiple dropdowns. The first one is an "Autocomplete" dropwdown generated from a simple textbox by using "sharepointservice". The user can choose a name there and I should find an ID based on the name in an outer Sharepoint list. But the names are not unique so there may be several ID reference. So I generate THIS dropdown and I would like to make the user select the correct ID to the name. After that I have to generate a new type of ID from the name+ID+date and the user can go next only if this is done so they have to choose eventualy. – Nefri Oct 10 '17 at 15:19
  • Also I am started both JS and Sharepoint about a week ago so, this was my solution I thinked, but I am open to any other more advanced way to solve it. – Nefri Oct 10 '17 at 15:20

1 Answers1

-1

I think that the best option would be to replace the dropdown list by a custom made one. Then you would have full control over it. Using some overlays may even prevent the user from doing anything else than select an item in your list.

Nenos
  • 129
  • 1
  • 2
  • 10
  • This does not answer the question. You don't have enough rep to comment yet. Please refrain from adding answers that don't fully answer the question. – Liam Oct 10 '17 at 14:50
  • This is a perfect example of an XY problem - OP wants to do something and has decided to do it with a select, which doesn't work as expected so asks question on select. This answer says: go back to the actual problem and reconsider an alternative. – freedomn-m Oct 10 '17 at 14:58