Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ldenman

macrumors regular
Original poster
Jul 20, 2005
229
0
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.
 

freiheit

macrumors 6502a
Jul 20, 2004
643
90
California
What language?

ldenman said:
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.

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.
 

angelneo

macrumors 68000
Jun 13, 2004
1,541
0
afk
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)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.