Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

Insert a character into a text ...

Javascript coding ..

Moderators: macek, egami, gesf

Insert a character into a text ...

Postby WoozyDuck » Sun Dec 05, 2004 5:49 am

Hi all

Ive used this function to insert a character in a text area:

Code: Select all
function addChar(inChar)
{
  document.getElementById("BlaBla").value = document.getElementById("BlaBla").value + inChar;
  document.getElementById("BlaBla").focus ();
}



it works perfect with IE , but it doesnt work in other brwosers!
can U help me how can I set this function working in all browsers?

Cheers
User avatar
WoozyDuck
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed May 05, 2004 10:14 am

Postby doctorcode » Mon Dec 06, 2004 4:26 am

Hi,
Which browser does not work with your script?
I test it with Firefox (0.9.3) and it runs fine.
It seems to me pretty standard Javascript code.
Let me know.
doctorcode
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Jul 23, 2004 3:27 am

Postby WoozyDuck » Mon Dec 06, 2004 3:16 pm

Hi

well I have 5 browsers installed on my computer to test the codes!
this code just works in IE! and it doesnt insert any character in
any other browser for me!
Ive tested it in another place too , even my friends did it too
but it just works on Internet Explorer !
I think there is something wrong with (getElementById)
or maybe (document)!!!

is there any other way to get an Element isntead of using those command
to add a character into it ?
User avatar
WoozyDuck
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed May 05, 2004 10:14 am

Postby swirlee » Tue Dec 07, 2004 7:18 am

I'm not a JavaScript expert, but from what I can tell your code should be woring on most modern browsers (I take this page as evidence). Try making sure that getElementByID returns an object that you expect, and so on.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby ruturajv » Wed Dec 08, 2004 7:39 pm

just use
Code: Select all
if( typeof documen.getElementById('sdfsf') == 'object' )
//object returned...
} else {
///
}
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.