0

I have this code here:

var first = orfirst;    
second = eval("document.love.name" +ea).value.toUpperCase();
var names=second;
second = second.replace(r,"");

with this code:

("document.love.name" +ea).value.toUpperCase();

I get an error: Uncaught TypeError: Cannot read property 'name1' of undefined

where:<input value='' name=name1 onkeyup=checnum(this) type=text size=15>

because they say that this code id deprecated: document.love.name I try to make it like this: second = eval("document.getElementById('name')" +ea).value.toUpperCase();.

and then I get this error: Uncaught SyntaxError: Unexpected number

Can anyone show me or correct the codes? THanks in advance.

MAXIMUM
  • 27
  • 3
  • 7
  • If youre using `getElementById()` you have to pass the name (`name1`) and not the type(`name`). You have to create an ID (let's say id1) and after it it should look like this: `getElementById('id1')`. PS: You didn't use quotes on the HTML part to assign the name of the input. – Tiago Salzmann Jan 11 '13 at 11:30
  • oh I forgot to tell I already made `name=name1` to `id=name1` so i can use `document.getElementById` – MAXIMUM Jan 11 '13 at 11:41

1 Answers1

2

What about adding an ID to the element and using the following code:

document.getElementById("name"+ea).value.toUpperCase();

Thanks to @Quentin and @Prisoner for spotting that there's no ID at present.

Kaiesh
  • 1,042
  • 2
  • 14
  • 21