Zynex
Feb 15th 2007, 1:33 am
I have made a system to add names to a list. I have 3 input text fields, and I gave them all a unique ID. But I can't manage to reach them with getElementByID. Could someone look into my code and tell me what I am doing wrong?
//this is the part were I made the input fields and there ID's//
<input type="Text" id="input" />
<input type="Text" id="search" />
<input type="Text" id="result" onFocus="blur()" />
--------------------------------------------------------------------
//this is were I use the getElent to reach the textfields by ID//
var inputField = document.getElementById('input');
var searchField = document.getElementById('search');
var resultField = document.getElementById('result');
--------------------------------------------------------------------
//this is how i've put it in the code//
function addName() {
if (inputField.value != '') {
namen.push(inputField.value);
}
} //addName
function searchArray() {
gevonden = 'nee';
for (j = 0; gevonden == 'nee' && j < namen.length; j++) {
if (namen[j] == searchField.value) {
gevonden = 'ja';
resultField.value = j;
}
else {
resultField.value = 'niet gevonden';
}
}
}
-----------------------------------------------------------------------
Thank you in advance!
Donny
//this is the part were I made the input fields and there ID's//
<input type="Text" id="input" />
<input type="Text" id="search" />
<input type="Text" id="result" onFocus="blur()" />
--------------------------------------------------------------------
//this is were I use the getElent to reach the textfields by ID//
var inputField = document.getElementById('input');
var searchField = document.getElementById('search');
var resultField = document.getElementById('result');
--------------------------------------------------------------------
//this is how i've put it in the code//
function addName() {
if (inputField.value != '') {
namen.push(inputField.value);
}
} //addName
function searchArray() {
gevonden = 'nee';
for (j = 0; gevonden == 'nee' && j < namen.length; j++) {
if (namen[j] == searchField.value) {
gevonden = 'ja';
resultField.value = j;
}
else {
resultField.value = 'niet gevonden';
}
}
}
-----------------------------------------------------------------------
Thank you in advance!
Donny