View Full Version : Drop Down Like Yahoo
soumik
11-16-2005, 02:27 AM
Hi to all,
i am looking for a drop down option inside a div like yahoo mail compose. like you start typing the email id in the text field and it shows a list of the options with the starting characters. i need to implement the same script over my project.
i hav a lot of names inside a combo box. i wil hav a text box where the user type a character; suppose "A" and it shows all the names starts of with "A" under the text field. samewise, if the user type "Ab" it shud show all the names starting off with "Ab".
and clicking the particular name in the box it takes u to a another page with the value.
please let me know if anyone has any problem to recognize the situation.
thanx in adv.
regards,
soumik.
konithomimo
11-16-2005, 01:59 PM
Perhaps something along the lines of:
<script type="text/javascript">
var l=0;
var mystring = document.getElementById('myinput').value;
function updateList()
{
var myarray = newArray();
var i;
for(i=0;i<menuname.length;i++)
{
myarray[i] = document.getElementById('menuID').options[i].value;
}
menuIt(myarray,myarray.length);
}
function menuIt(arrays,num)
{
var k;
var m;
var n=0;
var thisarray = newArray();
if (l == num)
{
for (m=0; m<arrays.length;m++)
{
document.getElementById('menuID').options[i].value = thisarray[i];
return true;
}
}
for(k=0;k<arrays.length;k++)
{
var j=0;
for(j;j<arrays.length;j++)
{
if (arrays[j].charAt(k) = = mystring.charAt(k))
{
thisarray[n] = arrays[j];
n++;
}
}
l++;
}
}
With 'myinput' and 'menuID' changed to whatever you have them as.
soumik
11-16-2005, 11:23 PM
Perhaps something along the lines of:
<script type="text/javascript">
var l=0;
var mystring = document.getElementById('myinput').value;
function updateList()
{
var myarray = newArray();
var i;
for(i=0;i<menuname.length;i++)
{
myarray[i] = document.getElementById('menuID').options[i];
}
menuIt(myarray,myarray.length);
}
function menuIt(arrays,num)
{
var k;
var m;
var n=0;
var thisarray = newArray();
if (l == num)
{
for (m=0; m<arrays.length;m++)
{
document.getElementById('menuID').options[i] = thisarray[i];
return true;
}
}
for(k=0;k<arrays.length;k++)
{
var j=0;
for(j;j<arrays.length;j++)
{
if (arrays[j].charAt(k) = = mystring.charAt(k))
{
thisarray[n] = arrays[j];
n++;
}
}
l++;
}
}
With 'myinput' and 'menuID' changed to whatever you have them as.
konithomimo,
can u please make a example with ur code. i really do not get into the script.
thanx...
soumik.
konithomimo
11-22-2005, 08:11 AM
I am not exactly sure what you mean. Just add this to your header and then call it when you need it. Here is another way to do it:
<script type="text/javascript">
var l=0;
var mystring = document.getElementById('myinput').value;
function menuIt(arrays,num)
{
var k;
var m;
var n=0;
var arrays = newArray();
var i;
for(i=0;i<menuname.length;i++)
{
arrays[i] = document.getElementById('menuID').options[i].value;
}
var num = arrays.length;
if (l == num)
{
for (m=0; m<arrays.length;m++)
{
document.getElementById('menuID').options[i].value =arrays[i];
return true;
}
}
for(k=0;k<arrays.length;k++)
{
var j=0;
for(j;j<arrays.length;j++)
{
if (arrays[j].charAt(k) != mystring.charAt(k))
{
arrays.splice(j,1);//remove the element that doesnt match
k--;
n++;
}
}
l++;
}
}
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.