Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Acces Objects Using String Variable: Is it Possible?

Reply
Thread Tools

Acces Objects Using String Variable: Is it Possible?

 
 
Himaxda0
Guest
Posts: n/a
 
      02-29-2004
Is it possible to access Objects like (document.form1.textfield1) with
a string variable like (var obName='textfield1') and using
(document.form1.obName.value)?
Ive tried it in IE but the value in the obName is not cosidered as a
object name. Help PLZ..
 
Reply With Quote
 
 
 
 
Ryan Stewart
Guest
Posts: n/a
 
      02-29-2004
"Himaxda0" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Is it possible to access Objects like (document.form1.textfield1) with
> a string variable like (var obName='textfield1') and using
> (document.form1.obName.value)?
> Ive tried it in IE but the value in the obName is not cosidered as a
> object name. Help PLZ..


See the FAQ which is posted here frequently or available here:
http://www.jibbering.com/faq/


 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      02-29-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Himaxda0) writes:

> Is it possible to access Objects like (document.form1.textfield1) with
> a string variable like (var obName='textfield1') and using
> (document.form1.obName.value)?


Yes, except not like that. It's even in the FAQ:
<URL:http://jibbering.com/faq/index.html#FAQ4_39>

First of all, the safest way to access the form control is:
document.forms['form1'].elements['textfield1'].value
i.e., through the forms and elements collections. That also makes
it easier to access using a string or string variable:
document.forms['form1'].elements[obName].value


/L
--
Lasse Reichstein Nielsen - (E-Mail Removed)
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
Not able to acces authentication tab wireless networkconnection pr =?Utf-8?B?bm9vcmQ0NTM=?= Wireless Networking 3 10-15-2004 07:59 PM
One or multiple command objects for ASP.NET app to MSSQL (or Acces =?Utf-8?B?QWxleCBGaW1pbmU=?= ASP .Net 1 09-11-2004 07:29 AM
How to acces all of the archieves of google using perl and NNTP protocal? help alex Perl Misc 1 05-24-2004 08:21 PM
Acces Excel file using .Net Reddy ASP .Net 2 12-01-2003 03:57 PM



Advertisments