I've got this code for a test script:
What i'm trying to do is to create a Select object next to a select object when the value of the original select is changed. The problem I'm facing is that I want the created Select to do the same thing when its value is changed. With the above code, i get a "too much recursion" error. I tried changing it so that the function did not take any parameters and just used 'this' instead of 'o', and changingCode:function change(o) { var newSelect, i; newSelect=document.createElement('select'); for(i=0; i<5; i++) { newSelect.options[i] = new Option(i,i); } newSelect.size="4"; newSelect.onchange=change(this); o.onchange=""; o.parentNode.appendChild(newSelect); }toCode:newSelect.onchange=change(this);but that breaks it with error that "this.parentNode has no properties".Code:newSelect.onchange=change;
And thus I come to you, oh gurus of Javascript, for help. Any ideas?




Bookmarks