I am getting data from the server and iterating over it to create a table 
and then I am using a form to store an id to local storage using 
javascript. Here is code snippet

<table>
    <tr><th>Product ID</th></tr>
    {{range .}}
    <td ><form onsubmit="save_data()" action="/" method="get"><button 
class="btn btn-info pid" id="pid" name="{{.puid}}" 
value="{{.puid}}">Update</button></form></td>
    {{end}}<table>
<script>
function save_data() {
  var input = document.getElementByID("pid");
  localStorage.setItem("id", input.value); 
}   
</script>


However every time, no matter of which table row's "update" button I click, 
everytime only the ID of the first table row element is getting stored. 
Is there a way I can generate unique IDs and reference it in Javascript when 
ranging over the data.
Thanks


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to