javascript - How to populate textboxes upon button click? -


i want create system needs textboxes populated current time , current data stored on $_session["username"]; upon clicking button.

i know how time stamp , data on $_session["username"];, need steps on how populate textboxes these data.

steps, modules or can lead me right direction appreciated, request make simple possible me able understand thoroughly.

here's code test, got time inside textbox. want first textbox blank upon clicking of button or textbox itself, populate current time./$_session["username"]`;.

<html> <body>  <?php   echo   date("y/m/d");  echo   "<br>";   $time= date("h:i:s a", strtotime("now"-8));   echo   "<input type=textfield name=time value='$time' size=9>"; ?>  </body> </html>  

let's assume sake of simplicity have on textbox , 1 button:

<input type="textfield" id="textbox" value='' size=9> <input type="button" value="click" onclick="document.getelementbyid('textbox').value='$time'"> 

the same go other textbox/button combination.

you have set onclick property of button execute javascript. in case, document.getelementbyid('textbox').value='$time'. use of single quotes important, or we'll ending onclick property.

we use document.getelementbyid('textbox') find text field, has id. tack on .value='$time'.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -