javascript - Creating a pulldown on website using values from php variable? -


i creating form user can add more fields form if need them data.

i using javascript function triggered action button creates row of textboxes , 1 pull down field.

however in row need pull down options "yes , no", have them in php array variable called $success

this have try , create pull down not working.

ta[n]=document.createelement('option'); ta[n].value = <?php echo $success; ?>; ta[n].name='success'+n; 

could me out time :)

this bulk of current code

if(inp[c].value=='add')      {        inp[c].onclick=function()          {            ta[n]=document.createelement('input');            ta[n].setattribute('rows',1);            ta[n].setattribute('cols',20);            ta[n].name='time'+n;            document.getelementbyid('txtara').appendchild(ta[n])            ta[n]=document.createelement('input');            ta[n].setattribute('rows',1);            ta[n].setattribute('cols',20);            ta[n].name='event'+n;            document.getelementbyid('txtara').appendchild(ta[n])            ta[n]=document.createelement('input');            ta[n].setattribute('rows',1);            ta[n].setattribute('cols',20);            ta[n].name='supplies'+n;            document.getelementbyid('txtara').appendchild(ta[n])           var sel = document.createelement('select'); 

here go (i think wanted do):

http://jsfiddle.net/maniator/4brz2/

var sel = document.createelement('select');  var ta = []; var n = 0;  ta[n]=document.createelement('option'); ta[n].value = 'yes'; ta[n].name='success'+n; ta[n].innerhtml = ta[n].value; n++; ta[n]=document.createelement('option'); ta[n].value = 'no'; ta[n].name='success'+n; ta[n].innerhtml = ta[n].value; n++;  sel.appendchild(ta[0]); sel.appendchild(ta[1]);   document.getelementbyid('here').appendchild(sel); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -