Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Variable in IMG SRC

Status
Not open for further replies.
You need to tell us what server-side scripting environment you are working in or whether you are using just straight HTML and relying on a pure Javascript solution.

If you are going the HTML/Javascript way... you need to collect the parameters off the URL, split the data pairs and confirm that you have something useful in a variable (that refers to the surname data).

Google for the following for details on how to do this (of course there are many resources that discuss this):

Parsing The Querystring with Javascript

Once the data is in a javascript variable, you can use the onload event to update the URL of the image (assuming you gave it an id) or you could document.write the image src "on the fly" as you build the page.

Google for getElementById and for document.write for more details on specific use of these commands.

Let us know how you get on.
Jeff
 
I am using straight HTML - I'm a novice. The img being referenced is on an external site I have no control over. Just need the easiest solution. I have had a look on google and its like a foreign language to me. 'surname' is always completed (form validation does this) - problem is just submitting it as part of the img src.

 
Excellent... you'll have no problem following the advice I posted initially then.

Let us know how you go,
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top