2017-07-10 1 views

Répondre

0

Si vous ne disposez pas d'un JQuery, vous pouvez le faire comme ceci:

<html> 
<head> 
</head> 
<body> 
    <form method="POST" id="dataForm" onsubmit="askAdditionalInfo()"> 
     <label for="name">Name</label> 
     <input id="name" name='name' type="text" /> 
     <input id='lastname' type="hidden" name='lastname'/> 
     <button type="submit">Submit</button> 
    </form> 
    <script> 
     function askAdditionalInfo(e){ 
      var lastName = prompt("Your last name?"); 
      document.getElementById('lastname').setAttribute('value', lastName); 
     } 
    </script> 
</body> 

Avec un JQuery, vous pouvez vous abonner à submit event

de la forme