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!

passing variables that are set from image object

Status
Not open for further replies.

walbr02

Technical User
May 15, 2002
14
US
Hello,
I am trying to build an admin page that allows the admin to change out images on their web site. I think that my problem is simple, but I still cannot find the answer.
I am setting the variable = document.image.src, but when I pass the variable via mypage.htm?variable=value, I end up passing the entire" as the variable.

Is there a way to just pass the image.gif when referencing a document image object?

Any help would be greatly appreciated!
Brian
 
when you add the path of the image to the url escape it ie:

path = "mypage.htm?variable="+escape(value)
 
Thanks for the quick response. I have tried escape, and it still is referencing the entire path:

var location1 = document.loc1.src
document.location.href = "update.cfm?location1=" + location1

Any ideas?
Thanks!
 
strip the document.domain from the location1 string ie

var location1 = document.loc1.src;
var docdom = document.domain;
location1 = location1.substring(docdom.length+8);

this should return what you need, replace that 8 with a 9 for https

len(" +len("/") = 8
len(" +len("/") = 9

thats where the 8 and 9 came from, im sure this problem has a better solution, this is just the quickest, i think
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top