Hi I have this javascript code that works fine. It is a dropdown menu that selects employee's name. Then it will automatically direct to leave_approve_process.php
that will display any related information about the employee.
However, how can I change the code so that it will open leave_approve_process.php
in a new tab. Please help me as I'm new to this javascript. Thanks.
$employee = mysqli_query("SELECT * FROM employee");
<script type="text/javascript">
function showUser()
{
var str1=document.getElementById('employee').value;
if (str1=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","leave_approve_process.php?id="+str1,true);
xmlhttp.send();
}
</script>
<form name="form2" id="form2" method="post" action="">
<select name="employee" id="employee" onChange="showUser()" class="validate[required]">
<option value="">Select one</option>
<?php
while($row_sem=mysqli_fetch_array($employee))
{
echo "<option value='". $row_sem['emp_id'] ."'>". $row_sem['emp_name'] ."</option>";
}
?>
</select>
</form>
<br />
<div id="txtHint" align="center"></div>