0
I have an HTML page with a form and a table, I need to insert information in this small form and show in the table using only Javascript, but I’m not getting.
The Javascript file is external, as shown in my HTML page below:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> Formulario </title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<br/>
<br/>
<div class="row">
<div class="col-md-12">
<div class="container">
<!-- Formulario -->
<form role="form">
<div class="form-group">
<label for="nome">Nome:</label>
<input type="email" class="form-control" id="nome">
</div>
<div class="form-group">
<label for="sobrenome">Sobrenome:</label>
<input type="text" class="form-control" id="sobrenome">
</div>
<div class="form-group">
<label for="telefone">Telefone:</label>
<input type="text" class="form-control" id="telefone">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form> <!-- /Formulario -->
</div>
</div>
</div>
<br/>
<br/>
<div class="row">
<div class="col-md12">
<div class="container">
<table class="table">
<thead>
<th> Nome: </th>
<th> Sobrenome: </th>
<th> Telefone: </th>
</thead>
<tbody>
<tr>
<td> Bla </td>
<td> Bla </td>
<td> Bla </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/script.js"></script>
</body>
</html>
I would like to put the Javascript encoding in the script.js file, which is linked in the HTML page.
I have tried to save the form information in variable and object array in Javascript, but when displaying nothing happens.
Does anyone have any idea how to do?
Welcome, Rafael. Also enter the code of the script.js.
– Pablo Almeida
Hello Pablo, thanks! There was nothing in the script.js file, as I had saved only the variable information I thought would not be useful. Anyway now I have an idea of what to do. Thank you for your attention!!
– Rafael Dantas