Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

update select field options

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use javascript to update a <select> field <option> values in a form. Can anyone please confirm if I have to refresh the page when I assign the option objects to the field?

Meaning, when I do a selectfieldname.options[num]=new Option(...)

doI have to refresh the page?? are the changes supposed to take effect immediately?My whole app page hangs up

regards,
Brian
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do not refresh the page ... that would wipe out any DOM changes you would have made.

Rather than relying on updating the array -- which is an iffy practice -- use the standardized API for the select element (which has an add method).
[ February 24, 2006: Message edited by: Bear Bibeault ]
 
Brian Percival
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,

I think I read about that page refresh in devguru site for javascript where it says to do a histry.go(0) after adding new Option() objects. It wasn't working and I wasn't sure. So I had to ask

regards,
Brian
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
never heard of having to use hostroy.go before....

Eric
 
He does not suffer fools gladly. But this tiny ad does:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic