Greetings!
I have recently decided that I'm not too fond of the standard "SELECT" control (list box) that microsoft provides, so I've decided that I'm going to try and create my own.
Before I go any further, if this has already been done, please direct me to where I can get ahold of that code.
Here are the requirements...
1. The code must reside in a separate .js file.
2. The code must allow for multiple list boxes on a single page, so each must be given a separate name.
3. The code must store the value, displayed text, and other basic functions that a typical list box would provide.
4. The code must be flexible enough so I can add functions like highlighting on mouse over, etc.
I would like to create the list box as an object, so that in the HTML page that houses the custom list box, I can simply code something like:
Creating the object is where I'm stuck. lol, I know that's not very far, but once I can grasp this, I think the rest should be fairly simple.
Based on other code I've seen, here is what I have so far.
The htm file...
The js file...
Currently, I'm getting an error on line 6 of the htm file saying that "objList1" is undefined.
I know that my problem is in the js file, as even what I have now doesn't make a whole lot of sense. Perhaps I'm too used to VBScript. Is there anyone who could give me a push here?
Thank you much!
He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
I have recently decided that I'm not too fond of the standard "SELECT" control (list box) that microsoft provides, so I've decided that I'm going to try and create my own.
Before I go any further, if this has already been done, please direct me to where I can get ahold of that code.
Here are the requirements...
1. The code must reside in a separate .js file.
2. The code must allow for multiple list boxes on a single page, so each must be given a separate name.
3. The code must store the value, displayed text, and other basic functions that a typical list box would provide.
4. The code must be flexible enough so I can add functions like highlighting on mouse over, etc.
I would like to create the list box as an object, so that in the HTML page that houses the custom list box, I can simply code something like:
Code:
alert(objList1.GetValue(2));
Based on other code I've seen, here is what I have so far.
The htm file...
Code:
<HTML>
<HEAD>
<SCRIPT TYPE="text/javascript" SRC="CustomListBox.js"></SCRIPT>
<SCRIPT type=text/javascript>
alert(objList1.GetValue(2));
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT type=text/javascript>BuildListBox("objList1");</SCRIPT>
</BODY>
</HTML>
Code:
//Arrays
var aryText = new Array();
var aryValue = new Array();
function BuildListBox(strName){
eval(strName + " = new ListBoxObject()");
}
function ListBoxObject(){
aryValue[0] = "value 0";
aryValue[1] = "value 1";
aryValue[2] = "value 2";
aryValue[3] = "value 3";
}
function GetValue(intIndex){
return aryValue[intIndex];
}
Currently, I'm getting an error on line 6 of the htm file saying that "objList1" is undefined.
I know that my problem is in the js file, as even what I have now doesn't make a whole lot of sense. Perhaps I'm too used to VBScript. Is there anyone who could give me a push here?
Thank you much!
He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon