|
-
Feb 24th, 2006, 08:07 AM
#1
Thread Starter
Addicted Member
javascript
I know that its not asp net but I need some help in javascript.
hope thats ok.
I have select with 3000 records
and its hard to find the value
I think to do array in javascript and textbox.
and when I write in the textbox "pa"
i call the javascript function (onkeypress)
and the select change just the records start with "pa"
like "parent, paper ..."
I sure that is many example in the web, but I didnt find it,
if someone show this example, I'll happy th get the link 
thanks!
-
Feb 24th, 2006, 12:08 PM
#2
Re: javascript
You want the auto-suggest feature. In what? What control do you want this implemented in?
-
Feb 24th, 2006, 12:55 PM
#3
Re: javascript
Hey, yeah, I've done this code before....
It ain't for the feint of heart tho, nor for slow browsers...
To set it up, then all of the rows on your table with results all need to have an id property set to "trow"
<TR id="trow">
Then, for my specific example, each row has three table cells that have data I want to search. Those cells have IDs of "td_1" through "td_3"
<td id="td_1">First Cell with Text</td>
And here is the function I use to do all the searching:
Code:
function searchFor(inVal){
var trows;
var found;
counter=0;
trows = document.all("trow");
for(var i=0; i < trows.length; i++){
found=false;
if(trows[i].all('td_1').innerText.toUpperCase().indexOf(inVal.toUpperCase()) > -1)found=true;
if(trows[i].all('td_2').innerText.toUpperCase().indexOf(inVal.toUpperCase()) > -1)found=true;
if(trows[i].all('td_3').innerText.toUpperCase().indexOf(inVal.toUpperCase()) > -1)found=true;
if(found){
trows[i].style.display='';
}else{
trows[i].style.display='none';
}
}
return 0;
}
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Feb 24th, 2006, 12:59 PM
#4
-
Feb 24th, 2006, 01:00 PM
#5
Re: javascript
Yeah, it aint pretty, but it does do the job.
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Feb 24th, 2006, 01:01 PM
#6
Re: javascript
Have you started working on ASP 2.0 yet, Lord_Rat?
-
Feb 24th, 2006, 01:02 PM
#7
Re: javascript
No, unfortunately I have projects in 1.1 that still need completing. Once I finish them, then I will be moving up to 2.0
Is there some nice features I should know about?
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Feb 25th, 2006, 06:46 PM
#8
Re: javascript
I haven't started it either, but am hearing about more of it as I go along. I lost my VS 2005 DVDs... it's in another country right now! 
But you can look forward to lots of neat features in ASP 2.0, off the top of my head right now, I can think of...
Atlas
Master Pages
Compiling web services on-the-fly
SQLDataSources (although I'm not too eager about this)
A decent treeview control. That actually works. No, really. I saw it for myself.
-
Feb 25th, 2006, 06:47 PM
#9
Re: javascript
I haven't started it either, but am hearing about more of it as I go along. I lost my VS 2005 DVDs... it's in another country right now! 
But you can look forward to lots of neat features in ASP 2.0, off the top of my head right now, I can think of...
Atlas
Master Pages
Compiling web services on-the-fly
SQLDataSources (although I'm not too eager about this)
A decent treeview control. That actually works. No, really.
-
Feb 25th, 2006, 07:10 PM
#10
Thread Starter
Addicted Member
Re: javascript
Lord_Rat
first thanks
I use your code
I have a small problem
I take the data from database then I have customID (int)
and customName(char)
how can I insert the data to the array?
show my code
here is my code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
#searchCustom{position:realitive}
#customer{
position: absolute;
width: 143px;
height: 136px;
left: 11px;
top: 39px;
display:block;
}
</style>
<script language="javascript" type="text/javascript">
c = new Array ()
c[0]="aplle"
c[1]="drafd"
c[2]="drff"
c[3]="ddrff"
c[4]="aasedd"
c[5]="cgfgv"
c[6]="uigg"
c[7]="dwdgd"
c[8]="asedg"
c[9]="cdsd"
c[10]="cces"
c[11]="sdeedd"
c[12]="ccdu djjdn jdjd"
c[13]="olajdf hydbdj"
c[18]="מחוץ למערך"
function create()
{
var oSelect = document.getElementById("customer");
for (var i = 0; i <=c.length-1 ; i++)
{
oOption = document.createElement("option");
oOption.value = i.toString();
oOption.innerHTML= c[i].toString();
oSelect.appendChild(oOption);
}
}
function searchFor(inVal){
var oSelect = document.getElementById("customer");
while(oSelect.childNodes.length>0)
{oSelect.removeChild(document.getElementById("customer").childNodes[0])}
if (inVal.length == 0) //אם אין תוכן בתיבת הטסקט למלא את כל הערכים
{
document.getElementById("customer").style.display = "block";
for (var i = 0; i <=c.length-1 ; i++)
{
oOption = document.createElement("option");
oOption.value = i.toString();
oOption.innerHTML= c[i].toString();
oSelect.appendChild(oOption);
}
}
else
{
document.getElementById("customer").style.display = "block";
//מחיקת הערכים
var found;
for(var i=0; i < c.length; i++)
{
//הוספת הערכים הרלוונטיים
found=false;
if(c[i].indexOf(inVal) > -1)found=true;
if(found)
{
oOption = document.createElement("option");
oOption.value = i.toString();
oOption.innerHTML= c[i].toString();
oSelect.appendChild(oOption);
}else{}
}
return 0;
}
}
function selectedItem(t)
{
document.getElementById("searchCustom").value =t.options[t.selectedIndex].text;
document.getElementById("searchCustom").name = t.value;
document.getElementById("customer").style.display = "none";
}
function showSelect()
{
var objDiv = document.getElementById("customer") ;
objDiv.style.display = (objDiv.style.display=="none") ? "block" : "none" ;
}
</script>
</head>
<body onload="create()">
<form id="dd">
<input name="searchCustom" id="searchCustom" type="text" onkeyup="searchFor(this.value)"/>
<input name="" type="button" onClick="showSelect()" />
<select name="customer" id="customer" size="5" onchange=" selectedItem(this)">
</select>
</form>
</body>
</html>
-
Feb 25th, 2006, 07:25 PM
#11
Re: javascript
 Originally Posted by mendhak
I haven't started it either, but am hearing about more of it as I go along. I lost my VS 2005 DVDs... it's in another country right now!
But you can look forward to lots of neat features in ASP 2.0, off the top of my head right now, I can think of...
Atlas
Master Pages
Compiling web services on-the-fly
SQLDataSources (although I'm not too eager about this)
A decent treeview control. That actually works. No, really. I saw it for myself.
isn't that what MSDN downloads are for???
-
Feb 25th, 2006, 07:43 PM
#12
Re: javascript
 Originally Posted by kleinma
isn't that what MSDN downloads are for???
There's another story going on there with MSDN Subscriptions, but essentially, I'm stuck in an awkward limbo at the moment... And it's not even my fault.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|