M.HosNS
6
Q:

insert value to html input with javascript variable

function product(a, b) {
   return a * b;
}
function setInputValue(input_id, val) {
    document.getElementById(input_id).setAttribute('value', val);
}
0

  
    <form 
    action="/action_page.php">

  <label for="fname">First name:</label>
  <input type="text" id="fname" 
    name="fname" value="John"><br><br>
  <label for="lname">Last 
    name:</label>
  <input type="text" id="lname" name="lname" 
    value="Doe"><br><br>
  <input type="submit" value="Submit">

    </form>
  
 
4

New to Communities?

Join the community