We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

damarev on 10/10/06


Tagged


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

luman


set Select List To Value


Published in: JavaScript 


  1. function setSelectListToValue(value, selectId){
  2. var i, si, v, args=setSelectListToValue.arguments;
  3. if ((obj=document.getElementById(args[1])) != null){
  4. v = args[0];
  5. for(i=0; i<obj.length; i++){
  6. if(obj.options[i].value == v){
  7. si = i;
  8. }
  9. }
  10. obj.selectedIndex = si;
  11. }
  12. }

Report this snippet 

You need to login to post a comment.