Answer the question
In order to leave comments, you need to log in
How to get highest range values in golang template?
I have a form
<form method="POST" action="/saveLucr">
{{ range .Proflist }}
<b> <input name="name_lucru" type="text" value="{{ .NameProf }}" /> </b>
<b> <input name="orar_prof" type="text" value="{{ .OrarProf }}" /> </b>
<label id="addProfesie">add profesie</label>
<table id="{{ .NameProf }}">
<tbody>
{{ range .PersList }}
<tr name = "tr" id = "tr">
<td> Numele: <input name="name" type="text" value="{{ .NameLucr }}" /></td>
<td> Prenumele: <input name="surname" type="text" value="{{ .PrenumeLucr }}" /></td>
<td> Concediu I inceput: <input name="date_begin_concediu1" type="date" value="{{ .Begconc1 }}" /></td>
<td> Concediu I terminat: <input name="date_end_concediu1" type="date" value="{{ .Endconc1 }}" /></td>
<td> Concediu II inceput: <input name="date_begin_concediu2" type="date" value="{{ .Begconc2 }}" /></td>
<td> Concediu II terminat: <input name="date_end_concediu2" type="date" value="{{ .Endconc2 }}" /></td>
<td class="delete_button"> <label id="del_tr1">Del</label> </td>
</tr>
{{ end }}
</tbody>
</table>
<P><label id="addLucrator">Add_Lucrator</label></P>
{{ end }}
<input type="submit" value="GO!">
</form>
{
"Proflist" : [
{"NameProf" : "inj",
"OrarProf" : 8,
"PersList" : [
{
"NameLucr" : "grisa",
"PrenumeLucr" : "fas",
"Begconc1": "5",
"Endconc1" : "0",
"Begconc2": "0",
"Endconc2" : "0"
},
{
"NameLucr" : "vasea",
"PrenumeLucr" : "fas2",
"Begconc1": "4",
"Endconc1" : "2",
"Begconc2": "4",
"Endconc2" : "5"
}
]},
{"NameProf" : "ing2",
"OrarProf" : 10,
"PersList" : [
{
"NameLucr" : "hhh",
"PrenumeLucr" : "dsa",
"Begconc1": "dsa",
"Endconc1" : "asd",
"Begconc2": "dsadfsadfasfas",
"Endconc2" : "kasdhfkjhasjkd"
}
]}
]
}
< <tr name = "tr" id = "tr">
<tr name = "tr" id = "tr_{{ .NameProf }}">
Answer the question
In order to leave comments, you need to log in
Create iteration variables for outer loop:
<form method="POST" action="/saveLucr">
{{ range $i, $p := .Proflist }}
<b> <input name="name_lucru" type="text" value="{{ $p.NameProf }}" /> </b>
<b> <input name="orar_prof" type="text" value="{{ $p.OrarProf }}" /> </b>
<label id="addProfesie">add profesie</label>
<table id="{{ $p.NameProf }}">
<tbody>
{{ range $p.PersList }}
<tr name = "tr" id = "tr_{{ $p.NameProf }}">
<td> Numele: <input name="name" type="text" value="{{ .NameLucr }}" /></td>
...
</tr>
{{ end }}
</tbody>
</table>
<P><label id="addLucrator">Add_Lucrator</label></P>
{{ end }}
<input type="submit" value="GO!">
</form>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question