multiple select: Selections not highlighted
Hi
I implemented multiselect from the result of mysql query. I am not able to select the options because of the javascript's autoSubmit() function. The autoSubmit() reset the variable after each selection. How to modify this autoSubmit() function so that it works for multiple select also.
Any suggestion?
Any suggestion?
Thanks
Fahim
<?php
$conn = mysql_connect('localhost', 'root', 'fahim');
$db = mysql_select_db('rugit',$conn);
if (!$db) die("Unable to connect to MySQL: " . mysql_error());
$arrTypeTarget = null; //declare vars
if(isset($_GET["arrTypeTarget"]) && is_string($_GET["arrTypeTarget"]))
{
$arrTypeTarget = $_GET["arrTypeTarget"];
}
?>
<script language="JavaScript">
function autoSubmit()
{
var formObject = document.forms['theForm'];
formObject.submit();
}
</script>
<form name="theForm" method="get" enctype="multipart/form-data">
<?php
$query = strtolower("show tables like \"human%\"");
print("query is $query");
$result = mysql_query($query, $conn);
$nRows = mysql_num_rows($result);
print"nRows is $nRows";
?>
<br></br>
Select the target array type: <br>
<select name="arrTypeTarget[]" size = "5" multiple="multiple" id = "arrTypeTarget" onChange="autoSubmit();">
<?php
print("result is $result");
while($row = mysql_fetch_array($result))
{
echo ("<option value=\"$row[0]\" " . ($arrTypeTarget == $row["0"] ? " selected" : "") . ">$row[0]</option>");
}
echo"</select><br>";
$val = implode(", ", $_GET["arrTypeTarget"]);
print("arrTypeTarget is: $val");
?>
</form>