what is difference b/w document.getelementid And document.gettagname

Posted by Asrinu under JavaScript on 7/29/2010 | Views : 3340 | Status : [Member] | Replies : 2
what is difference b/w document.getelementid And document.gettagname




Responses

Posted by: Webmaster on: 7/29/2010 [Administrator] HonoraryPlatinum

Up
0
Down
You can specify two attribute to identify any of the HTML controls

either "id" or "name"
for example

<input type="text" id="txtAddress" name="txtAddress1" />


If you want to find this text box using id, you can use document.getElementById('txtAddress") and if you want to find this text box using its name you can use document.getElementByName("txtAddress1");

It is not necessary to specify same id and name attribute of the html element. Older version of IE was not capable of identifying the id property, it used to find the element only with its name.

Now, if you specify the Id property its enough to work in the client side however to access an html element at the server side you will have to specify its name. For example, above article can be accessed in the server side by using Request.Form["txtAddress1"].

Hope this helps.

Thanks for asking and happy learning.



Best regards,
Webmaster
http://www.dotnetfunda.com

Asrinu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: BangaruBabu on: 7/31/2010 [Member] Starter

Up
0
Down
http://www.webdeveloper.com/forum/showthread.php?t=230997

BangaruBabu Pureti
http://bangarubabupureti.spaces.live.com/

Asrinu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response