Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Preview Background URL

    Very very simple javascript but giving me a little problem.

    I have an input box.
    Code:
    <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:
    Code:
    <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?

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,274
    Thanks
    28
    Thanked 271 Times in 265 Posts
    Quote Originally Posted by lostron View Post
    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?
    Code:
    <a onclick="document.getElementById('container').style.backgroundImage = 'url(\'' + document.getElementById('imageurl').value + '\');">Preview</a>
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • Users who have thanked Arbitrator for this post:

    lostron (08-23-2008)

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks that fixed it!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •