Wednesday, January 06, 2010

Happy New Year 2010

Happy New Year 2010

Monday, January 04, 2010

Javascript: getElementById works only in IE - Solution

I always find wierd problems and solutions to it everytime I use javascripting. This is one of the many which I would like to share with you all. Logically the solution is easy if you have the following kind of code:

in javascript code:

var v = document.getElementbyID("test").value;

and you code has hidden value of test in it probably like:



The above code works fine in IE browser and fails in firefox or other browsers. Simple solution is we are not used to add id in the input tag and we are calling element by Id. so I solution for above is either change in javascript:

var v = document.getElementbyName("test").value;

or in the code as:


Easy isnt it. Let me know if things are more complicated than this. I will try to find solution. :).

LinkWithin

Related Posts with Thumbnails