tags:

views:

82

answers:

3

How can I send image path to the function? My code is:

<a href="#" onclick="addElement(this.id);" id="cricket" tabindex="1">Cricket</a> 

I want to send my image path in the function addElement along with the id.

A: 

How the image path may be, are you defined the image path?

if you defined the image path, can workout like that

  <a href="#" onclick="addElement(this.id,'<?php echo "images/img.gif";?>');" id="cricket" tabindex="1">Cricket</a>
Karthik
ya but how can i send image path without php tag
rajesh
Provide striaghtly like that<a href="#" onclick="addElement(this.id,'images/img.gif');" id="cricket" tabindex="1">Cricket</a>
Karthik
but my problem is that when i write functionfunction addElement(vlc,imgs){ var element=vlc; var element1=imgs; alert(element1);its not showing image but alerting image path.....please provide solution thanks....
rajesh
If you alert a string, you get a string appearing in an alert window. You can't display images in an alert box.
David Dorward
how can you get the image in alert box? Only path rajesh. Now you are in right move. Proceed further.
Karthik
I'll repeat: You **can't** display images in an alert box.
David Dorward
… and that isn't the question you asked.
David Dorward
thank u all for ur valuable suggestion .......i got my ans....
rajesh
+1  A: 

addElement(this.id, this.getAttribute('href'));

TriLLi
but my problem is that when i write function function addElement(vlc,imgs){ var element=vlc; var element1=imgs; alert(element1); its not showing image but alerting image path..... please provide solution thanks....
rajesh
That isn't the question you asked though.
David Dorward
can you explain to me what is image path??
TriLLi
A: 

I see what you're trying to do, but no, it is impossible to show an image in an alert window, the funcion window.alert() won't allow it in any possible way but not all is lost, if you wish to explore some alternatives you can try this link http://code.google.com/p/submodal/ which is a way to do something similar to what you seem to need, or you can try to use CSS to accomplish it if you're just trying to show an image.

Ozmah