<form action="{{.Page}}" name="form1" id="form1" method="POST" target="iframename" onsubmit="event.stopPropagation(); event.preventDefault();">
<table id="input4Form" style="vertical-align: middle;">
<tr>
<td></td><td colspan="4"><b>{{.Title}}</b></td>
</tr>
<tr>
<td style="text-align: right;">{{.Label1}}</td>
<td><input id="value1" type="text" name="value1" title="{{.In1_Title}}" maxlength="60" onkeydown="if (event.keyCode == 13) document.getElementById('input2search').click()"/></td>
<td> </td>
<td style="text-align: right">{{.Label2}}</td>
<td><input id="value2" type="text" name="value2" title="{{.In2_Title}}" maxlength="60" onkeydown="if (event.keyCode == 13) document.getElementById('input2search').click()"/></td>
<td> </td>
<td style="text-align: right">{{.Label3}}</td>
<td><input id="value3" type="text" name="value3" title="{{.In3_Title}}" maxlength="60" onkeydown="if (event.keyCode == 13) document.getElementById('input2search').click()"/></td>
<td> </td>
<td><input type="button" id="input2search" value=" Go " onclick="event.stopPropagation(); event.preventDefault();loadBySubmit2('form1');"/>
</td>
</tr>
</table>
</form>
<script type="text/javascript">
document.getElementById('value2').addEventListener('keydown', getdefAD);
document.getElementById('value1').focus();
function getdefAD(val1){
if (val1.keyCode == 9) {
$.post('erp/getDefaultValue?attr=' + $("input#value2").val() +'&id=' + $("input#value1").val(), function(data) {
if (data) $("input#value3").val(data);
});
}
}
</script>
This is the response handler to return a value from the database:
//Get default value for attribute
func getDefaultValue(w http.ResponseWriter, r *http.Request) {
sA := "attr"
sP := r.URL.Query().Get(sA)
sA = "id"
sI := r.URL.Query().Get(sA)
if dataAccess.IsStringInSlice(sP, dataAccess.SlcAD_Default) {
sR := dataAccess.GetERPADDefault(sP, sI)
fmt.Fprintf(w, "%s", sR)
} else {
//sR = dataAccess.GetERPADDefault(sP, sI)
//fmt.Fprintf(w, "%s", sR)
// fmt.Println("Not found")
return
}
}