Name an object

P

Paul

How do I create and refer to an object as the following isn't recognised,
where as if I replace myfield with LinkLocation4536, it recognises the field
in form List
function confirmDelete(wid)
{

var myfield="LinkLocation" + wid

alert(document.forms["List"].myfield.value);

}
 
E

Erwin Moller

Paul said:
How do I create and refer to an object as the following isn't recognised,
where as if I replace myfield with LinkLocation4536, it recognises the
field in form List
function confirmDelete(wid)
{

var myfield="LinkLocation" + wid

alert(document.forms["List"].myfield.value);

}

Hi,

document.forms["List"].myfield.value will just fetch the value of a
formelement named myfield. Which is not what you want.

Does the following code work?

function confirmDelete(wid)
{
alert ("wid="+wid);
var myfield="LinkLocation" + wid
alert(document.forms["List"][myfield].value);
}



Regards,
Erwin Moller
 
P

Paul

"Erwin Moller"
message
Paul said:
How do I create and refer to an object as the following isn't recognised,
where as if I replace myfield with LinkLocation4536, it recognises the
field in form List
function confirmDelete(wid)
{

var myfield="LinkLocation" + wid

alert(document.forms["List"].myfield.value);

}

Hi,

document.forms["List"].myfield.value will just fetch the value of a
formelement named myfield. Which is not what you want.

Does the following code work?

function confirmDelete(wid)
{
alert ("wid="+wid);
var myfield="LinkLocation" + wid
alert(document.forms["List"][myfield].value);
}



Regards,
Erwin Moller

Hi

No that comes up with an expected identifier error but...............

alert (eval ("document.forms['List'].LiveLinkLocation" + wid + ".value") );

does

Cheers

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top