javascript - How to create an input field and then prepopulate the field with -
please no jquery.
i've seen several examples of input field exists on page before update it, i'd dynamically create input field , populate information available page (hence current_value variable defined above code snippet):
for (i=0; i<tables.length; i++) { (function(i) { var sp = document.createelement('span'); var act_table = document.createelement('table'); act_table.id = 'act-tests-' + i; act_table.style.display = 'none'; var test_name_input = document.createelement('tr'); test_name_input.innerhtml = '<tr><td width="100px">name</td><td><input type="text" class="widevalue testname input"></td></tr>'; test_name_input.setattribute('value', current_rule); act_table.innerhtml ='<tbody><tr>lots of table rows here</tr></tbody>'; act_table.insertbefore(test_name_input,act_table.firstchild); sp.appendchild(act_table); } the field being shown not populated current_value.
any appreciated.
in example set attribute tr, instead of created input field. try this:
document.getelementsbyclassname("input")[you_index].setattribute("value", current_value); here example: http://jsfiddle.net/35g0ks0t/
Comments
Post a Comment