Variables in the Javascript DOM

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
denz
Forum Newbie
Posts: 18
Joined: Fri Jun 24, 2005 4:18 pm

Variables in the Javascript DOM

Post by denz »

Hi all

I would like to update a field on the web page based on a radio button checked. The radio button has the same id as an image, so if i select radio button with the id of 6 i would like to be able to get the src of img with the id of 6 and move it the the opener page

i've tried this:

Code: Select all

opener.document.img1thumb.src = "test.jpg"
which works perfectly

however when i try this:

Code: Select all

opener.document.img1thumb.src =  document.img + imgdat +.src
i get a syntax error. (btw, i have a small function that loads the id of the checkbox into a variable called imgdat)

any ideas how to pass a variable into the DOM?

Thanks
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

take a look at getElementById().

something like:

Code: Select all

document.getElementById('img'+imgdat).src
should work.
denz
Forum Newbie
Posts: 18
Joined: Fri Jun 24, 2005 4:18 pm

Post by denz »

Wonderful, you're a hero again!

8)
Post Reply