Home Show values in lable based on combox which linked to DB
Reply: 1

Show values in lable based on combox which linked to DB

Mahmood Abdullah
Mahmood Abdullah Published in 2018-01-13 09:28:39Z

here is my try to pass the valuse into label based on combox. suppose I choose A from combox the labe must change to 1 if i select B, the lable change to the 2.

here is my try:


$sel = mysql_select_db('test',$conn);
$query=mysql_query('select * from alamat where jalan="'.$alamat.'"');
while ($data=mysql_fetch_array($query)){
echo '<label value= "' .$data[2].'"> <b> ' .$data[2].' </b> </label>;



<!DOCTYPE html>
   <title>Test Calculator</title>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="css.css">
   <link type="text/css" rel="stylesheet" href="style.css"/>
   <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Oswald">
   <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open Sans">
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
   <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
   <script src="//code.jquery.com/jquery-1.10.2.js"></script>
   <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 
   <script src="jquery.min.js"></script>
      <label> Jalan: </label>
      <select name="alamat" id="alamat" onchange=kota(this.value)";>
         <option value=""> --Items -- </option>
         <?php $j1=mysql_query($con,'select * from alamat order by id ASC');
            while ($jalan=mysqli_fetch_row ($j1)){
            echo '<option value="'.$jalan[1].'</option>';
      <label> </br></br> kota:</label> <label name="kota" id="kota"> <b> label</b><label>
jasinth premkumar
jasinth premkumar Reply to 2018-01-13 11:42:53Z

javascript takes place here

you want to change label value to index of selected option

function myfun(select) {

  document.getElementById('some').innerText = select.selectedIndex;
<select onchange="myfun(this)" id=s>
<option value=" ">0</option>
<option value="3">2</option>
<option value="4">3</option>
<label id=some></label>

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.31343 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO