probably a simple solution

Discussion in 'Mac Programming' started by ldenman, Apr 25, 2006.

  1. macrumors regular

    Joined:
    Jul 20, 2005
    #1
    i am creating a web app. I need to know how to take text the user inputs (specifically an image url) and put that url in the <img src=""> tags.
    does anyone know how this would be accomplished?

    edit: i guess this should be in the web forum. my bad.
    I am using RoR though, so it sorta counts.
     
  2. macrumors 6502a

    Joined:
    Jul 20, 2004
    Location:
    California
    #2
    What language?

    It depends entirely on what language you are using for your web app. Are you using Perl? PHP? Python? ASP? JavaScript? When you say RoR I have a feeling you mean Ruby On Rails but I'm not certain.
     
  3. thread starter macrumors regular

    Joined:
    Jul 20, 2005
  4. thread starter macrumors regular

    Joined:
    Jul 20, 2005
  5. macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #5
    Can I assume that this is javascript? It makes more sense if it is.

    Let's just say a person clicks on a button (onClick, onChange, onBlur so on) and as long as you have the id to your img tag and input tag, just do the following:
    Code:
    document.getElementById('image_tag_id').src = document.getElementById('input_text_id').value
    
    or you can
    Code:
    document.getElementById('image_tag_id').setAttribute('src', document.getElementById('input_text_id').value)
    
     

Share This Page