Javascript value of option when load in page -


i'm stuck on this, , use anyone.

my question is: how load default value in select element when page opens?

in other words, when page first loads, select element has option selected, without user having interact it. otherwise, if user wants select else, can use select element other options.

<p>select league list.</p>  <select id="myselect" onchange="myfunction()">   <option value="<iframe src='http://www.tablesleague.com/iframe?width=232&height=430&font_name=tahoma&position=1&font_size=12&team_link=1&link_color=404040&games=1&wins=1&draws=0&lost=0&goals=0&goals_against=0&gd=0&points=1&next=0&form=0&font_size=12&font_color=000000&bg_color=ffffff&header_font_color=ffffff&header_bg_color=1fb9e4&bg_col=1fb9e4&font_color_col=ffffff&highlight=e3e3e3&hover=fff6bf&league_header=1&league=l_145&team=&timezone=7&language=2&team_flags=0' width='232' height='500px' frameborder='0' scrolling='no'></iframe>" selected="selected">premier league   <option value="<iframe src='http://www.tablesleague.com/iframe?width=232&height=430&font_name=tahoma&position=1&font_size=12&team_link=1&link_color=404040&games=1&wins=1&draws=0&lost=0&goals=0&goals_against=0&gd=0&points=1&next=0&form=0&font_size=12&font_color=000000&bg_color=ffffff&header_font_color=ffffff&header_bg_color=1fb9e4&bg_col=1fb9e4&font_color_col=ffffff&highlight=e3e3e3&hover=fff6bf&league_header=1&league=l_474&team=&timezone=7&language=2&team_flags=0' width='232' height='430' frameborder='0' scrolling='no'></iframe>">seria   <option value="bbva">bbva   <option value="bundes">bundes </select> <p id="demo"></p>  <script> document.getelementbyid('myselect').value = ''; function myfunction() {     var x = document.getelementbyid("myselect").value = '';     document.getelementbyid("demo").innerhtml = x; } </script> 

you have value selected using selected attribute on html.

with

document.getelementbyid('myselect').value = ''; 

you wiping current value. try removing line.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -