CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   Can not pass ID with dot(.) and (-) to javacript (http://www.codingforums.com/showthread.php?t=287562)

Tamanna16 02-13-2013 06:23 AM

Can not pass ID with dot(.) and (-) to javacript
 
Html code:
<input id="text.id" type="text" onFocus="dosomething(this,'text1.id')">
<input id="text1.id" type="text">

i am trying to do something like above, i'm trying to pass id(text1.id) with function dosomething() but its not working.
please help me.

:confused:

durangod 02-13-2013 06:31 AM

use the _ not the dot, i dont think . is a legal name character..


text_id

Tamanna16 02-13-2013 06:37 AM

Thank you for your reply durangod. but can't change ID name. i have to go with text1.id.
any other suggestion???

Philip M 02-13-2013 07:22 AM

Quote:

Originally Posted by Tamanna16 (Post 1312999)
Thank you for your reply durangod. but can't change ID name. i have to go with text1.id.
any other suggestion???

Well, in that case you are in the craperoo as the Australians would say. A period (dot) is not a legal character in an element id (or a name).

felgall 02-13-2013 07:34 AM

That id wouldn't work for anything else either - not just JavaScript.

In CSS #text.id would be looking for an element with id="text" and class="id" and wouldn't match the id you have.

I can't think of why someone would want to target an input field but I doubt that <a href="text.id"> would link to that field properly either.

That's all three possible uses for an id with at least two and probably all three of them not working when the id contains an illegal dot.

Tamanna16 02-13-2013 08:41 AM

thank you all for your valuable reply....
My work is done.
:)

VIPStephan 02-13-2013 10:14 AM

Quote:

Originally Posted by felgall (Post 1313003)
I can't think of why someone would want to target an input field but I doubt that <a href="text.id"> would link to that field properly either.

The ID on inputs is used for labels. I don’t know whether the link is made if there is a period in the ID, though.

felgall 02-13-2013 09:08 PM

Quote:

Originally Posted by VIPStephan (Post 1313033)
The ID on inputs is used for labels. I don’t know whether the link is made if there is a period in the ID, though.

It appears that the id does still work for linking a label to an input even when the id contains garbage - at least in all the popular browsers. That is the one instance where a period doesn't apply a different meaning in one place to what it does at the other. You wouldn't be able to access the forHTML value from JavaSript though because it too would misinterpret the dot.


All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.