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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IsDefined() ? 1

Status
Not open for further replies.

FALCONSEYE

Programmer
Jul 30, 2004
1,158
0
0
US
i have the following

<input type="image" name="delete" src="btn_delete_a.gif" onClick="return confirm('Are you sure to delete this spot?');">

on the action page, when i try to check and see if this image is clicked, i get nothing.
<cfif IsDefined('form.delete')>
defined
<cfelse>
undefined
</cfif>

moreover, when i <cfdump> the form values, i do not see this
'delete' under FORM.FieldNames.
what can i do to check if this image is clicked?
thanks for the help in advance...
 
if you're going to be putting an event in that will confirm something you shouldn't do it onclick, you should do it onsubmit.

you should also show your whole form...

Beware of programmers who carry screwdrivers.
 
It's probably better to create a hidden form field and set its value when the user clicks on your image. Apparently different flavors of browser treat image type values differently; see for an interesting discussion about this.

That said, try inserting a value attribute in the tag.

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'm not as think as you confused I am.
-----------
Flabbergasted (a.): Amazed at how much weight one has gained.
-----------
Oyster (n.): One who sprinkles their conversation with Yiddish expressions.
 
When an image is clicked to submit a form, the image field is not passed with the form, but two fields called "X" and "Y" are, if I recall correctly (maybe "delete.X"). If your "delete" image is the only image that can be used, you could try checking for those fields.

However, what I have found to work better is something more like this:

Code:
<a href="/deleteitem.cfm?id=72828"><img src="/images/delete.gif" border=0></a>

--OR--

<a href="javascript:if(confirm('Are you sure?'))location.href='/deleteitem.cfm?id=72828';"><img src="/images/delete.gif" border=0></a>

... and just not even worry about incorporating delete ability into the same form. Do your deletion on a separate page from your other processing. You can also do this with an input type="button" and onClick="location.href, etc.
 
Joe, yes you are right. I didn't see the delete.X and delete.y fields in the <cfdump> at first. after i did a
<cfif StructKeyExists(FORM, 'delete.X')>
defined
<cfelse>
undefined
</cfif>

it works just like how i wanted.
also, this works like a charm

<input type="image" name="delete" src="btn_delete_a.gif" onClick="return confirm('Are you sure to delete this spot?');">

thanks ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top