naamabm Posted November 30, 2010 Share Posted November 30, 2010 Is there a way to remove (not disable and not delete) an option in a "select" list, and restore it later when needed?I have a form with many huge lists ("select" with many "options") that depend on eachother. I am dynamically updating the form through server, and wish to update the list values by sending a mask string. This way I could remove and restore the options without the need to pass the whole list again.I tried many ways but none work:* option.diabled="disabled" is not good because it is still shown* option.style.visibility='hidden' is not good because it is still taking a row* option=null is not good because I will not be able to restore itI need a method similar to the following one for remove/add fields in a form:remove:<field>.style.display='none';restore:<field>.style.display=block';Thank you!!! Link to comment Share on other sites More sharing options...
[dx] Posted November 30, 2010 Share Posted November 30, 2010 You could use SQL.You can make table with list of it and with while or foreach, you can call whatever you want.Or you could make 2 select box. And when one is selected, will show some values, and other, will show others. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 30, 2010 Share Posted November 30, 2010 It would be most efficient if you could do it on the server with something like PHP so that you only send the markup that is needed instead of sending the entire list and then using Javascript to hide parts of it. Link to comment Share on other sites More sharing options...
jeffman Posted November 30, 2010 Share Posted November 30, 2010 If the updated data is coming by way of AJAX, that of course is not a solution. It's also not a solution if a change to one element creates a predictable change to a second element, and you want the response to be immediate.You might want to use the select object's add/remove methods for the purpose of display, and keep permanent track of your data in one or more JavaScript structures. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.