...

View Full Version : Problems with getElementByID



Zynex
02-15-2007, 10:43 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

BubikolRamios
02-15-2007, 04:59 PM
before this line:

namen.push(inputField.value);

put

alert(inputField);

does it show [object] or something like that, if it does then the problem is .value . Specify the error returned next time.

Regards.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum