简体   繁体   中英

How do I populate my textboxes?

I am making a website for my internship and I came across a problem. Retrieving data from my database into my textboxes. If possible, each person their own information. For example; I have a textbox for John, he has a name and email. Jack also has a name and email. Both need to be selected from the database and put in the form. It's a form where you can make changes to the persons information. You can see the website yourself here . Click on the button "Wijzig" to view the form I mean.

 <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> </head> <tr> <td width="100"> <div id="flip"> <img src="images/ik.jpg" class="circular" width="100px" height="100px"> <td width="350px"> <label for="luca" style="width: 280px;">Luca Fraser</label> <div id="panel" style="display: none;">Geboortedatum: 30-12-1997 <br>Email: lucaf1997@gmail.com <br>Woonplaats: Winterswijk </div> </td> </div> </td> <td> <label for="luca">Voorzitter</label> </td> <td style="border-color: transparent;"> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModalNorm" style="background-color: #42a5f5; border-color: #42a5f5; margin-left: 20px;">Wijzig </button> <div class="modal fade" id="myModalNorm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <!-- Modal Header --> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> <span aria-hidden="true">&times;</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title" id="myModalLabel"> Wijzigen </h4> </div> <!-- Modal Body --> <div class="modal-body"> <form role="form"> <div class="form-group"> <label for="exampleInputEmail1">Voornaam</label> <input type="email" class="form-control" id="exampleInputEmail1" value="Here needs to get a input value, look at line 247 to see where it needs to be." /> </div> <div class="form-group"> <label for="exampleInputEmail1">Achternaam</label> <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Janssen" /> </div> <div class="form-group"> <label for="exampleInputEmail1">Email</label> <input type="email" class="form-control" id="exampleInputEmail1" placeholder="jan@janssen.nl" /> </div> <div class="form-group"> <label for="exampleInputPassword1">Telefoonnummer</label> <input type="text" class="form-control" id="exampleInputPassword1" placeholder="0612345678" /> </div> <div class="form-group"> <label for="exampleInputEmail1">Functie</label> <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Voorzitter" /> </div> </form> </div> <!-- Modal Footer --> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal"> Close </button> <button type="button" class="btn btn-primary"> Save changes </button> </div> </div> </div> </div> </td> <td style="border-color: transparent;"> <button type="button" class="btn btn-danger" onclick="myFunction()">Verwijder</button> </td> </tr> 

you need to write jquery code to get values from labels or DOM elements and display on respective input boxes.

value = $("#labelid").val();

But you need to make your HTML standardize like use unique id's for labels.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM