0

I have a select element in HTML. I save just selected value in DB. When I want to edit this element in users side , I need to show value that selected before. I see this link. but in this link user himself determines default value,while I want to have an editable select element.
I should first retrieve selected value from DB , then set it as default value to my select element. how can I do it in JavaScript?

Community
  • 1
  • 1
Saman
  • 5,173
  • 6
  • 17
  • 17
  • JavaScript alone can't do this. See http://stackoverflow.com/questions/5610333/how-to-query-database-using-javascript – musical_coder Oct 19 '13 at 18:52
  • Why do you want to set it via JavaScript? You can set `selected` attribute in backend to your desired `option` element. See [docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select) here – Mohsen Oct 19 '13 at 18:53
  • @Mohsen: in my project , Admin can edit any select element. I want to show to admin the value that selected before then edit it. I think it cant do by backend. – Saman Oct 19 '13 at 19:02
  • @musical_coder: how can I do it in Asp.net? – Saman Oct 19 '13 at 19:03
  • That's a broad topic, but this will get you started: http://msdn.microsoft.com/library/k4cbh4dh.aspx – musical_coder Oct 19 '13 at 19:18
  • what's wrong with setting the SelectedIndex property of the dropdownlist?! – deostroll Oct 19 '13 at 20:48

0 Answers0