469,951 Members | 2,485 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,951 developers. It's quick & easy.

aceess to a text using Id

Hi,
I've an html page that contains a form, inside the form Ive the folowing
input
<input name="myName" id="myId" size="40" >

I know how to access to it in javascript using its name
document.forms[0].myName

How Can I access to it using its Id?

I need this because in the case of a select, the name is an array (because I
need it in php)

Thanks.
Jul 20 '05 #1
5 1215
On Wed, 3 Mar 2004 18:04:31 -0500, toufik toufik <to*****@sympatico.ca>
wrote:
I've an html page that contains a form, inside the form Ive the folowing
input
<input name="myName" id="myId" size="40" >

I know how to access to it in javascript using its name
document.forms[0].myName

How Can I access to it using its Id?


[snip]

"hak" <s_**********@hotmail.com> also asked this question in the thread
"How can I use the id in javascript", posted Wed, 3 Mar 2004 21:04:28 GMT.

Monitor that thread instead of starting a new one.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2

"toufik toufik" <to*****@sympatico.ca> wrote in message
news:Zv********************@news20.bellglobal.com. ..
Hi,
I've an html page that contains a form, inside the form Ive the folowing
input
<input name="myName" id="myId" size="40" >

I know how to access to it in javascript using its name
document.forms[0].myName

How Can I access to it using its Id?
document.getElementById("myId")

i believe this should work for IE and Netscape. And also will work for
things other than forms.
I need this because in the case of a select, the name is an array (because I need it in php)

Thanks.

Jul 20 '05 #3
Lee
toufik toufik said:
I need this because in the case of a select, the name is an array (because I
need it in php)


http://www.jibbering.com/faq/#FAQ4_25

Jul 20 '05 #4
DU
toufik toufik wrote:
Hi,
I've an html page that contains a form, inside the form Ive the folowing
input
<input name="myName" id="myId" size="40" >

I know how to access to it in javascript using its name
document.forms[0].myName

How Can I access to it using its Id?

I need this because in the case of a select, the name is an array (because I
need it in php)

Thanks.


Are you T. Ouriachi?
If several form elements have the same name, then
document.forms[0].myName.item(index)
http://www.w3.org/TR/2000/REC-DOM-Le...ml#ID-349467F9

Best would be to avoid sharing the same name for form controls.

DU
Jul 20 '05 #5
Thanks friends,

DU; I'm not T. Ouriachi. ;-)

"DU" <dr*******@hotWIPETHISmail.com> wrote in message
news:c2**********@news.eusc.inter.net...
toufik toufik wrote:
Hi,
I've an html page that contains a form, inside the form Ive the folowing
input
<input name="myName" id="myId" size="40" >

I know how to access to it in javascript using its name
document.forms[0].myName

How Can I access to it using its Id?

I need this because in the case of a select, the name is an array (because I need it in php)

Thanks.
Are you T. Ouriachi?
If several form elements have the same name, then
document.forms[0].myName.item(index)

http://www.w3.org/TR/2000/REC-DOM-Le...ml#ID-349467F9
Best would be to avoid sharing the same name for form controls.

DU

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by pradeep gummi | last post: by
9 posts views Thread by Pam Ammond | last post: by
4 posts views Thread by Arif Çimen | last post: by
11 posts views Thread by pardesiya | last post: by
reply views Thread by chandrasekhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.