jquery - Multiple javascript selected from dropdown cannot seem to co-exist -
i building dynamically created string in multiple dropdown downs being looked @ values etc..
html: <div id="codesnip">where ... </div>
then on button click javascript function called:
function applyfilters(val) { var x = document.getelementbyid("codesnip"); var newdiv = document.createelement("div"); var newcontent = document.createtextnode("hi there , greetings!"); //var column = []; //$('[id^=selectnumber] :selected').each(function(i, selected){ //column[i] = $(selected).text(); var conditions = []; $('[id^=condition] :selected').each(function(z, selected){ conditions[z] = $(selected).text(); //newcontent = document.createtextnode(column[i]); //x.appendchild(newcontent); //add text node newly created div. newcontent = document.createtextnode(conditions[z]); x.appendchild(newcontent); newcontent = document.createtextnode(" , "); x.appendchild(newcontent); });
i cannot seem have both dropdowns exist without there being error on original column creator has nothing @ runtime alerts , console.log report nothing.
error: uncaught syntaxerror: missing ) after argument list
- (which different function dynamically creates dropdowns) comment out one of 2 dropdowns named selectnumber or condition - works. not sure why these both cannot used.
update: did make changes suggested similar error in creating function.
uncaught syntaxerror: unexpected token }
which function :
function columncreator(columnarray, selectid) { var dropdown = document.getelementbyid(selectid); (var = 0; < columnarray.length; ++i) { // append element end of array list dropdown[dropdown.length] = new option(columnarray[i], columnarray[i]); } }
that error exists because arguments list never closed:
$('[id^=selectnumber] :selected').each(callback);
after callback, statement needs closed. et someting this:
function applyfilters(val) { var x = document.getelementbyid("codesnip"); var newdiv = document.createelement("div"); var newcontent = document.createtextnode("hi there , greetings!"); var column = []; $('[id^=selectnumber] :selected').each(function(i, selected){ column[i] = $(selected).text(); newcontent = document.createtextnode(column[i]); x.appendchild(newcontent); //add text node newly created div. }); var conditions = []; $('[id^=condition] :selected').each(function(z, selected){ conditions[z] = $(selected).text(); newcontent = document.createtextnode(conditions[z]); x.appendchild(newcontent); }); newcontent = document.createtextnode(" , "); x.appendchild(newcontent); }
Comments
Post a Comment