the option value for select is from database now i have no idea to call the option in jquery
here my php code :
<table class="user"> <tr><td><select class="form-line" name="user[]" id="user"> <option value=""> Choose</option> <? include("../config_db/config_db_user.php"); $que_user= "SELECT * FROM user WHERE idinfouser != '1' ORDER BY name ASC"; $res_user = mysqli_query($db_conn_user,$que_user); while ($row_user= mysqli_fetch_array($res_user)){ ?> <option value="<? echo $row_user["idinfouser"]; ?>"><? echo $row_user["name"]; ?></option> <? } ?> </select> </td> <td> <button type="button" name="add" id="add" class="btn bg-light-green waves-effect">add</button> </td></tr></table> after i click add it suppose to add new selection using jquery
this is my jquery/javascript code :
<script> $(document).ready(function () { var counter = 1; $("#add").on("click", function () { counter++; var newRow = $("<tr>"); var cols = ""; cols += '<td> <select class="form-line" name="user[]"' + counter +'id="user"><option value="">Choose</option></select></td>'; cols += '<td><button type="button" name="remove" id="remove" class="btn btn-danger btn_remove">Remove</button></td>'; newRow.append(cols); $("table.user").append(newRow); }); $("table.user").on("click", "#remove", function (event) { $(this).closest("tr").remove(); }) }); and now the problem is how to get option value from the database same as in the table
https://stackoverflow.com/questions/66450651/how-to-get-database-in-option-value-in-jquery-javascript-and-mysqli March 03, 2021 at 12:07PM
没有评论:
发表评论