...

View Full Version : Preview Background URL



lostron
08-23-2008, 04:52 AM
Very very simple javascript but giving me a little problem.

I have an input box.

<input name="imageurl" type="text" id="imageurl" value="http://www." size="75">

Then a preview link that changes the background image of a certain div:

<a href="#" onClick="document.getElementById('container').style.backgroundImage= 'url(ImageHere)' " >Preview</a>

As you can see, if the "ImageHere" was a static image it works perfectly. However, i want it to take the value of the imageurl input text.

How can I do this?
:thumbsup:

Arbitrator
08-23-2008, 09:01 AM
As you can see, if the "ImageHere" was a static image it works perfectly. However, i want it to take the value of the imageurl input text.

How can I do this?
<a onclick="document.getElementById('container').style.backgroundImage = 'url(\'' + document.getElementById('imageurl').value + '\');">Preview</a>

lostron
08-23-2008, 02:11 PM
Thanks that fixed it! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum