Hi
I am using AJAX to display the value in selection/list box. this code is working fine in Firefox Mozila browser but it is not working in Internet Explorer so please tell me how this will work in both'
thanks!
I am using AJAX to display the value in selection/list box. this code is working fine in Firefox Mozila browser but it is not working in Internet Explorer so please tell me how this will work in both'
Code:
for html
<html>
<head>
<script src="addlist.js" type="text/javascript"></script>
</head>
<body>
<script language="javascript" type="text/javascript">
function my_submit_form() {
obj = eval("document.form1.expbox");
ki = 0;
if (obj)
{
var iNumItems = obj.length;
// create product order
for (i = 0; i < iNumItems; i++ )
{
if( obj.options[i].selected )
{
if (ki == 1)
{
document.form1.myExp.value += ':' + obj.options[i].value;
}
else
{
document.form1.myExp.value = obj.options[i].value;
ki = 1;
}
}
}
}
}
</script>
<form method="get" name="form1">
<input type="hidden" name="what" value="project">
<input type="hidden" name="myExp" value="">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="36%" ><select name="expbox" style="width:350px;" multiple="multiple" size="7" onChange="my_submit_form()">
<option value="Shyam">Shyam</option>
<option value="Sunder">Sunder</option>
<option value="Mahendra">Mahendra</option>
<option value="Kumar">Kumar</option>
<option value="Rajesh">Rajesh</option>
<option value="Singh">Singh</option>
<option value="Ganesh">Ganesh</option>
<option value="Panday">Panday</option>
<option value="Mohit">Mohit</option>
<option value="Mishra">Mishra</option>
</select> </td>
<td width="64%" align="left" ><select id="insert" style="width:150px; visibility:hidden" size="10"></select></td>
</tr>
<tr>
<td colspan="2"><input type="button" class="button" value="Search >>" onclick="addlist(document.form1.myExp.value)"></td>
</tr>
</table>
</form>
</body>
</html>
Code:
for js page
var xmlHttp
function addlist(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="addlist.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged ;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("insert").style.visibility="visible";
document.getElementById("insert").innerHTML+= xmlHttp.responseText+"<br>";
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
Code:
for php
<?php
$area = 0;
$exp1 = $_GET["q"];
while ($a = each($_GET))
{
$exp1 = $_GET["q"];
$area = explode(":",$exp1);
}
?>
<?php
while(list(,$values)=each($area))
{
echo "<option value=$values>". $values."</option>";
}
?>
Comment