Try something like this:
Note I haven't tested this so some tweaking may be required.
HTML:
<html>
<head>
<base target="_top">
</head>
<body>
<div id="msg"></div><!-- You can add css to hide these and then turn them on with js as required -->
<div id="found"></div>
<form>
<input type="text" name="id" placeholder="Enter Employee ID" /><br />
<input type="button" value="Search" onClick="processForm(this.parentNode);" />
</form>
<script>
function processForm(obj) {
google.script.run
.withSuccessHandler((obj)=>{
if(!obj.msg) {
document.getElementById('found').innerHTML=`EmployeeId: ${obj.id} Name: ${obj.n} Age: ${obj.a} Designation: ${obj.d}`;
}else{
document.getElementById('found').innerHTML=`Message: ${obj.msg}`;
}
})
.search(obj);
}
console.log("My Code");
</script>
</body>
</html>
GS:
function mysearch(obj) {
const ss=SpreadsheetApp.getActive();
const sh=ss.getSheetByName('Sheet1');
const [hA, ...data]=sh.getDataRange().getValues();
let idx={};
let found=false;
hA.forEach((h,i)=>{idx[h]=i;});
for(var i=0;i<data.length;i++) {
if(data[i][idx['EmployeeID']]==obj.id) {
Logger.log({id:obj.id,n:data[i][idx['Name']],a:data[i][idx['Age']],d:data[i][idx['Designation']]});
found=true;
break;
}
}
if(found){
return {id:obj.id,n:data[i][idx['Name']],a:data[i][idx['Age']],d:data[i][idx['Designation']]};
} else {
return {msg:"Not found"}
}
}
function launchMyNewDialog() {
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutputFromFile('ah1'),'test');
}