0
I have a code in Rails with an input that loads files and a button that collects the name of the selected file through input:
<label id="myLabel" for="file"></label>
<%= file_field_tag 'file' %>
<br/>
<br/>
<button onclick="myFunction()">Salvar nome do arquivo</button>
Yes I mixed Html with Ruby code, but I don’t know what a Ruby code label looks like.
This is my JS code, but only the part of the name collection, which is what matters at the moment:
function myFunction() {
var x = document.getElementById('file').files[0].name;
alert(x);
}
How could I take the value of this function and store it in my scaffold?
My scaffold (which I would like to store it):
<p id="notice"><%= notice %></p>
<h1>Histórico</h1>
<table>
<thead>
<tr>
<th>Arquivos validados:</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @historicos.each do |historico| %>
<tr>
##ss<td><%= link_to 'Show', historico %></td>
</tr>
<% end %>
</tbody>
</table>
<%= link_to 'Voltar', root_path %>
<br>
Yes, I removed the box to type the texts until why the names would be obtained through my function so I did not see reason to own them I tbm removed the links to the other views(show, delete and Edit).
Thank you in advance!!!