1 Replies - 2547 Views - Last Post: 10 June 2011 - 01:49 PM

#1 hockey97  Icon User is offline

  • D.I.C Regular

Reputation: -77
  • View blog
  • Posts: 300
  • Joined: 25-September 08

How to store variable used for later?

Posted 06 June 2011 - 03:27 AM

Hi, I made a function in javascript with jquery code in it.

ok... I have a function that grabs information from a input html button. The button I grabbed the image source.

For example :

var image_path;

function(id,path,state){

image_path = path;

if(state == "process"){
we are go for deleting image. send request via post method to php code to delete the image.
}
if(state == "opened"){
if open then open up window asking if it's ok to delete image"
}
if(state == "closed"){
close window asking if it's ok to delete image.
stop process.
}
}



the above code is an example.

I wasn't to grab the image path location that the user click the delete button for.

thie button runs the above function. I want to store the locaiton in a variable.

because the same function is used when open our window to ask if it's ok to delete the image.

I want to store the image in a variable before opening the window. Then when the user clicks ok it will run this same function but will pass a process action.

will this work ?

This post has been edited by hockey97: 06 June 2011 - 03:52 AM


Is This A Good Question/Topic? 0
  • +

Replies To: How to store variable used for later?

#2 maniacalsounds  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 117
  • View blog
  • Posts: 469
  • Joined: 27-June 10

Re: How to store variable used for later?

Posted 10 June 2011 - 01:49 PM

I'm not quite sure that I completely understood your question.

Quote

I want to store the image in a variable before opening the window. Then when the user clicks ok it will run this same function but will pass a process action.


If you're wanting to save the url of an image, yes. It's just like any other variable: ex.
 var imgurl = "http://www.somesite.com/image.png";



Quote

I wasn't to grab the image path location that the user click the delete button for.

Or are you asking how to get an image URL when someone clicks on an image/button? If so, create a function that grabs the src of the image. Example:
function clicked() {
	var url = document.getElementById("img").src;
        window.alert(url.toString());
}


This post has been edited by maniacalsounds: 10 June 2011 - 01:49 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1