Hi guys, my first time here, hope someone can help me out here.
I wrote this test code to try out a script, and it works just fine on Firefox and Netscape, but it doesn’t work too well in IE.
Here’s the complete code (HTML + JavaScript):
[code=php]<html>
<head>
<title>Test Script</title>
<script type=”text/javascript”>
function writeAll() {
document.myForm.txtQueryStr.value = “”;
tmpVar = “SELECT * FROM “;
for (i=0, len=document.myForm.selTable.length; i<len; i++) {
tmpVar += document.myForm.selTable.options[i].value;
if (i != (len – 1)) {
tmpVar += “, “;
} //if
}
document.myForm.txtQueryStr.value = tmpVar;
}
</script>
</head>
<body>
<form name=”myForm” action=”query.php” method=”post”>
<p><table>
<tr>
<td>
<select size=”5″ name=”selTable” style=”width: 100px;”>
<option>k1</option>
<option>k2</option>
<option>k3</option>
<option>k4</option>
<option>k5</option>
<option>k6</option>
<option>k7</option>
</select>
</td>
</tr></table></p>
<p>
<textarea name=”txtQueryStr” rows=”5″ cols=”100″></textarea>
</p>
<p><input type=”button” name=”btnQuery” value=”List all attributes in textbox” onClick=”writeAll();”></p>
</form>
</body>
</html>
The resulting text in Firefox is [B]SELECT * FROM k1, k2, k3, k4, k5, k6, k7[B]SELECT
Can anyone help me figure out why this is happening? Thanks in advance!
rishi