Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Help with document.getElementById
Old 09-05-2007, 04:10 PM Help with document.getElementById
Novice Talker

Posts: 6
Trades: 0
Hello!

I am new to this forum. Can somebody help me to write img to div with: document.getElementById. I can't use style.backgroundImage, because i have to set image height and width. I tried:
document.getElementById('con').src="gallery/image1.jpg";

any help? thanx
Cico is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-05-2007, 04:26 PM Re: Help with document.getElementById
Super Talker

Posts: 130
Trades: 0
could you post a link to the page you're trying to use this on?
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Old 09-05-2007, 04:31 PM Re: Help with document.getElementById
Novice Talker

Posts: 6
Trades: 0
Quote:
Originally Posted by flann View Post
could you post a link to the page you're trying to use this on?
sorry, don't have it on web yet...
Cico is offline
Reply With Quote
View Public Profile
 
Old 09-05-2007, 04:36 PM Re: Help with document.getElementById
Super Talker

Posts: 130
Trades: 0
ok, what is happening with your code? Could you post a bit more of it so we can walk through it a bit more.
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Old 09-05-2007, 04:52 PM Re: Help with document.getElementById
Novice Talker

Posts: 6
Trades: 0
Quote:
Originally Posted by flann View Post
ok, what is happening with your code? Could you post a bit more of it so we can walk through it a bit more.
i have <div id="con"> in html and within html i call:
<a href="#" onmousedown="sI()"><img src="gallery/image1.jpg" width="80px" height="50" border="1px" /></a>

in external file i have this:

function sI(){
document.getElementById('con').src="gallery/image1.jpg";
}

and nothing happens...
Cico is offline
Reply With Quote
View Public Profile
 
Old 09-05-2007, 04:57 PM Re: Help with document.getElementById
Super Talker

Posts: 130
Trades: 0
try giving your img tag an id and then call that id using getElementById.
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Old 09-05-2007, 05:00 PM Re: Help with document.getElementById
Novice Talker

Posts: 6
Trades: 0
Quote:
Originally Posted by flann View Post
try giving your img tag an id and then call that id using getElementById.
can u write a simple code? thanx
Cico is offline
Reply With Quote
View Public Profile
 
Old 09-05-2007, 06:20 PM Re: Help with document.getElementById
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
can u write a simple code? thanx
We are not freelancer. And if we happen to be, we don't spend time here to give our work for free.
You have been given a solution, apply it yourself.

Jesus, those peoples asking for code rather than typing 5 keys on their keyboard....
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-07-2007, 02:12 AM Re: Help with document.getElementById
Novice Talker

Posts: 13
Name: Ham
Location: Singapore
Trades: 0
what do you want to do? change the picture or add a new one?
hafio is offline
Reply With Quote
View Public Profile Visit hafio's homepage!
 
Reply     « Reply to Help with document.getElementById
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.52198 seconds with 12 queries