php - How to put onclick event on a button whose values is coming from database -


i want add click event of change color when clicked on label values of label comes database. how may same?

 <legend>roti</legend>  <?php      $qu = mysql_query("select * submenu menu_id=33") or die(mysql_error());      while($f = mysql_fetch_array($qu)){  ?>  <p>      <label for="name"><?php echo $f['submenu']; ?></label>      <input type="hidden" name="name" id="name" value="<?php echo $f['id']; ?>">  </p>  <?php } ?> 

use onclick , give function name(here use changecolor() function name) shown below

 <label for="name" onclick="changecolor(this)"><?php echo $f['submenu']; ?></label> <!-- #### replace label code inside while loop -->    <script>  //########### add outside while loop...usually above closing body tag </body>     function changecolor(obj){         obj.style.color = "red";     }  </script> 


change label color on clicked.

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -