2

I have a object in my HTML site which I expand/add to with a little JavaScript bit (below) on button click.

Can I refresh the dropdown/select on it's own to show the new choices automaticaly or can I only do that via a whole page refresh?

<select name="Auswahl", id='s'> </select>
<script>
    var select = document.getElementById("s");  
    for (j = 1; j <= i; ++j){
        var opt = document.createElement('option');
        opt.value = opt.text = j;       
        select.add(opt);
    }
</script>
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Simon
  • 21
  • 1
  • both... but you need to give more info, for example where does this info come from? are you asp? php? – T McKeown May 24 '15 at 13:51
  • Just using JavaScript and HTML. The options are added via Button Clicks, so after each Button click I'd need it to refresh. – Simon May 24 '15 at 14:02
  • you can do the entire thing in js. – T McKeown May 24 '15 at 14:03
  • You should remove the comma in between the properties of your `select`. – das_j May 24 '15 at 14:18
  • Removed the comma, thanks, didn't notice that one. @ T McKeown: How? So far I only found how get to refresh the whole page, didn't find out how to refresh that single object. – Simon May 24 '15 at 14:29

2 Answers2

0

you can create a function to remove all child <option> nodes and assign that function to a button call Reset for example, that will remove all options in the drop down list.

Remove all child elements of a DOM node in JavaScript

Community
  • 1
  • 1
lightbringer
  • 835
  • 2
  • 12
  • 24
0

Yes u can change without refresh hole page. It easy with jquery and ajax, just google them.

emy
  • 664
  • 1
  • 9
  • 22