javascript - Creating form fields from user input -


i found code creates form fields based on number chose user.

<script type='text/javascript'>          function addfields(){             var number = document.getelementbyid("member").value;             var container = document.getelementbyid("container");             while (container.haschildnodes()) {                 container.removechild(container.lastchild);             }             (i=0;i<number;i++){                 container.appendchild(document.createtextnode("member " + (i+1)));                 var input = document.createelement("input");                 input.type = "text";                 input.name = "member["+i+"]";                 container.appendchild(input);                 container.appendchild(document.createelement("br"));             }         } </script>   <input type="text" id="member" name="member" value="">number of members: <br /> <input type="button" id="enterdetails" value = "enter details"onclick="addfields()"> <div id="container"/> </div> 

it works fine. want create elements names/values imported database. in php this:

<select name='smth'> <option value=""></option> <?php  $qry = $dbh->query("select * table");  while ($a = $qry->fetch(pdo::fetch_assoc)) { $smth = $a['smth']; echo "<option value='$smth'>".$smth."</option>"; } ?>  </select> 

need on how in javascript.

you cant database fields javascript. must use php or this.

maybe can you. here link. choose database , table, , select field names, , choose field's type of form (text area, text, radio button groups, etc) , push create. have bootstrap designed form , php insert code writed medoo (medoo.in).

you can use this. create database first , make form automaticly. copy code , paste pages.

also offer use meddo connect , use sql it. there sample in link form.min.php, includes database , user , pass information.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -