Hi,
I am trying to use value of the text box for the querying ..The
query is defined with in the a javaScript .
I am not able to get the Value.. inside the function.. However
"document.form.text.value" is getting the value.
How do we assign the value of javscript to PHP??? Is there a better way
,,,
Php is as follows:
<html>
<head>
<title>Search result</title>
</head>
<body bgcolor="#fffff0">
<?php
echo "<Script Language = \"JavaScript\">\n";
echo "function getNames()\n";
echo "{\n";
echo "alert(\"Inside the FUcntion\");\n";
$connection = mssql_connect("girishp", "sa", "") or die
("could not connect to server.");
$db = mssql_select_db("AZADMINGROUP", $connection) or die
("Could not select database");
$sql_employee = "Select E_Number,E_First_Name,E_Last_Name from
T_Employee where E_First_Name = \"$searchName\"";
echo "alert(document.searchEmpl.searchName.value);\n";
$result_employee = mssql_query($sql_employee, $connection) or die
("Coule not execute"); $count = 1;
while($row = mssql_fetch_array($result_employee)) {
$ENo = $row["E_Number"];
$val = $row["E_First_Name"];
$val = $val . $row["E_Last_Name"];
#echo "var val = document.searchEmpl.searchresult;\n";
$val = $val . " ( " . $ENo . " )";
echo "document.searchEmpl.searchResult.options[$count].value =
'$val';\n";
echo "document.searchEmpl.searchResult.options[$count].text =
'$val';\n";
$count++;
}
echo "}\n";
echo "</Script>\n";
echo "<form name=\"searchEmpl\" method=\"POST\"
action=\"Employee_Details.php\">\n";
echo "<h2><font color=\"#CC6699\">Search :</font></h2>\n";
echo "<hr color=\"#CC6699\">\n";
echo "<p><font color=\"#CC6699\"><b>Employee Name :
</b></font><input type=\"text\" name=\"searchName\"
size=\"20\"> \n";
echo "<input type=\"button\" value=\"Search\" name=\"searchButton\"
onClick=\"getNames();\"></p>\n";
echo "<p align=\"left\"><select size=\"1\" name=\"searchResult\">\n";
echo "<option>Search Result</option>\n";
echo "<option></option>\n";
echo "<option></option>\n";
echo "<option></option>\n";
echo "<option></option>\n";
echo "<option></option>\n";
echo "<option></option>\n";
echo "<option></option>\n";
echo "<option></option>\n";
echo "<option></option>\n";
echo "</select> <input type=\"submit\" value=\"Show
Details\" name=\"B3\">
</p>\n";
echo "</form>\n\n";
?>
</body>
</html>
TIA
Girish