php - Insert hidden text inside selectbox option -
i have selectbox displays name , surname list of people. want add id each of them , make invisible. ex. if have john smith id 001 want write john smith:001 , should seen john smith. important id not unseen doesn't take space.
this code:
$result = pg_query(connect(), "select id, name, surname person order name asc, surname asc"); $person = pg_fetch_all($result); echo '<select value="person" name="person">'; for($i=0; $i<sizeof($person); $i++) { $person = $person[$i]['name'].' '.$person[$i]['surname']; echo "<option>".$person."<span hidden>:".$person[$i]['name']."</option>"; } echo '</select>';
however, isn't working because id remains visible
try setting value combined name , id (further comment):
<?php $result = pg_query(connect(), "select id, name, surname person order name asc, surname asc"); $person = pg_fetch_all($result); ?> <select name="person"> <?php for($i=0; $i<sizeof($person); $i++) { $name = $person[$i]['name'].' '.$person[$i]['surname']; ?> <option value="<?php echo $name.":".$person[$i]['id']; ?>"><?php echo $name; ?></option> <?php } ?> </select>
gives like:
array ( [person] => doug johnson:1 )
Comments
Post a Comment