php - How can I prevent the ID from showing in the datalist element? -
i trying utilize datalist element. working 1 little hitch. selectable list showing 2 columns, both street_id , street columns. need street_id submitted dont want street_id show in datalist.
<?php require 'connect_mysqli.php'; $sql = "select * streets"; $result = mysqli_query($con, $sql) or die ("error " . mysqli_error($con)); ?> <form action="test.php" name="test" method = "post"> <datalist id="street" name="streets"> <?php while($row = mysqli_fetch_array($result)) { ?> <option value="<?php echo $row['street_id']; ?>"><?php echo $row['street']; ?></option> <?php } ?> </datalist> <input type="text" name="street_val" id="test" autocomplete="off" list="street"> <input type="submit" value="submit"> </form> <?php mysqli_close($con); //test output value echo $_post['street_val'];// ?>
you have coded select list - has separate values display , returned values. in datalist, need value="" options , return value. better keep server code , display code separate: i.e. populate or build array in php query, in html display it.
Comments
Post a Comment