I am getting 'options' is null or not an object using when using a dynamic dataset with a dropdown list in an html form. I am filling-in a text field and filtering the values in the drop-down. This functionality works with a fixed set of values in the drop-down (i.e. <option value tags). Any insight would be greatly appreciated. -
<INPUT TYPE="text" NAME="input1" VALUE="" ONKEYUP="autoComplete(this,this.form.OBDataSet__135_1,'value',true)">
-
<select size="1" name="OBDataSet__135_1" onChange="this.form.input1.value=this.options[this.selectedIndex].value">
-
</select></td>
-
-
-
<script>
-
-
function autoComplete (field, select, property, forcematch) {
-
var found = false;
-
alert("field " + field.value);
-
// alert("select " + select.options[i][property]);
-
alert("property " + property);
-
alert("forcematch " + forcematch);
-
alert("index" + document.form1.OBDataSet__135_1.selectedIndex);
-
alert("text" + document.form1.OBDataSet__135_1.options[0].text);
-
for (var i = 0; i < select.options.length; i++) {
-
//for (var i = 0; i < 4; i++) {
-
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
-
found=true; break;
-
}
-
}
-
if (found) { select.selectedIndex = i; }
-
else { select.selectedIndex = -1; }
-
if (field.createTextRange) {
-
if (forcematch && !found) {
-
field.value=field.value.substring(0,field.value.length-1);
-
return;
-
}
-
var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
-
if (cursorKeys.indexOf(event.keyCode+";") == -1) {
-
var r1 = field.createTextRange();
-
var oldValue = r1.text;
-
var newValue = found ? select.options[i][property] : oldValue;
-
if (newValue != field.value) {
-
field.value = newValue;
-
var rNew = field.createTextRange();
-
rNew.moveStart('character', oldValue.length) ;
-
rNew.select();
-
}
-
}
-
}
-
}
-
-
-
</script>
-
5 11935
you can try using document.GetElementById
put an id on the select box and use the get element by id instead of document.form
this may fix your problem.
I appreciate you patience with this. Would you be willing to help me with the syntax of using your code with the code I have provided? I have tried GetElementById a few different ways, and continue to get errors.
Heres what I got for you bud, hope this helps you out let me know your results. -
<INPUT TYPE="text" NAME="input1" id="input1" VALUE="" ONKEYUP="autoComplete(this,document.getElementById('OBDataSet__135_1'),'value',true)">
-
<select size="1" name="OBDataSet__135_1" id="OBDataSet__135_1" onChange="document.getElementById('input1').value=this.options[this.selectedIndex].value">
-
<option>Test</option>
-
<option>Apple</option>
-
<option>Candy</option>
-
<option>Corn</option>
-
</select></td>
-
-
-
<script>
-
-
function autoComplete (field, select, property, forcematch) {
-
var found = false;
-
//alert("index" + document.getElementById("OBDataSet__135_1").selectedIndex);
-
//alert("text" + document.getElementById("OBDataSet__135_1").options[0].text);
-
for (var i = 0; i < select.options.length; i++) {
-
if (select.options[i].text.toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
-
found=true;
-
break;
-
}
-
}
-
if (found) { select.selectedIndex = i; }
-
else { select.selectedIndex = -1; }
-
if (field.createTextRange) {
-
var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
-
if (cursorKeys.indexOf(event.keyCode+";") == -1) {
-
var r1 = field.createTextRange();
-
var oldValue = r1.text;
-
var newValue = found ? select.options[i].text : oldValue;
-
if (newValue != field.value) {
-
field.value = newValue;
-
var rNew = field.createTextRange();
-
rNew.moveStart('character', oldValue.length) ;
-
rNew.select();
-
}
-
}
-
}
-
}
-
-
-
</script>
-
Yes, the use of "options[i].text" vs. "options[i][property]" work. I very much appreciate the help. Can you tell me why this work?
-- new
select.options[i].text.toUpperCase().
-- old
select.options[i][property].toUpperCase()
i don't know what [Property] does or is so i removed it form the code and works like a charm... thats incorrect syntax.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joe |
last post by:
Hi All,
I am new to using the Access DB and I need some help if someone
is able to give it to me. What I want to do is get the names of
the columns of certain tables. Not the data in the table...
|
by: Noah Coad [MVP & MCP] |
last post by:
When working with a DataSet generated from a DataSet definitions file (.xsd
file), AutoComplete works fine for the first few times I press . after a
class, but it stops completing text usually...
|
by: mlarson |
last post by:
Hello,
I'm working on a page that dynamically creates listboxes and the
"options" that are added to the listbox. A user can then click on
buttons to either add or delete the "options" from one...
|
by: Brett |
last post by:
Not sure what the problem is here... Trying to update from a datagrid to an
access database using vb.net... Its not updating the database but Im not
getting any errors... Here is my code...
...
|
by: Jerry John |
last post by:
I am working in ASP.NET with C#. I have a text file which contains datas
with delimiters. For example:-
MSH|^~\$|DISCHARGE|CLAY COUNTY MEMORIAL|||200502110939|
I also have an XML file created...
|
by: jdzemke |
last post by:
I am trying to validate that a null value is not chosen from a dynamic dataset called "OBDataSet__135_1" when a form Submit operation is performed. To do this I have a javascript function called...
|
by: Jim |
last post by:
Hi guys,
I have an object which represents an "item" in a CMS "component" where
an "item" in the most basic form just a field, and a "component" is
effectively a table.
"item" objects can be...
|
by: renjucool |
last post by:
I am developing an online bug tracking system in asp.net.IT is implemented now in our office,at a time around 10-15 peoples are using.Web application is hosted in a local machine(core 2duo-1 gb...
|
by: rocketfire97 |
last post by:
I'm trying to call a COM object using C# but having no luck getting
values back for passed in ref objects.
I've tried the same call using VB.NET and can get data back. How would
I implement the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |