Time:
Scotland: Fri, 7:42 pm
Rhode Island: Fri, 2:42 pm
Florida: Fri, 2:42 pm
New Mexico: Fri, 12:42 pm
California: Fri, 11:42 am

Click here to visit Livelife365.com

Click here to visit nmdarts.com



Buy this Ad Space.

180px wide.

Please get in touch with KH@ if you are interested and make an offer.

CLICK HERE TO GET AUCTION BAR NOW
US$10 per year - Save $100s!
The Fabulously Unfair
WebX Auction Bar. For Ebay etc.
Ro-Sham-Bo the opposition. Laugh like Eric Cartman when you win! CLICK HERE NOW!


More information and sign-up.

WebXpertz Hosting.
Custom fit from $5pm. PHP/MySQL
You'll save money, we'll save money. Seems fair to me. Interested? If so Please PM me here and tell me what you need. Thanks!


Please click here for more information

For continued disscussion on this topic : Deleting an item


ecojohnson
07-10-2001, 06:10 PM
I have a form where the user has the option of deleting an item from a database. I have the following Javascript function set up:


function DeleteMe() {
if (confirm ("Are you sure you want to delete the selected project?")){
document.forms[0].submit();
}else{
return false
}
}

In the form, I have the following set for the Delete button:


<INPUT TYPE="submit" NAME="Button" VALUE="Continue">
<INPUT TYPE="submit" NAME="Button" VALUE="Save">
<INPUT TYPE="button" NAME="Button" VALUE="Delete" ONCLICK="DeleteMe()">

On my action page, I have the following code set up:


<IF IsDefined ("form.button")>
do this
<ELSE>
do that
</IF>


If the user selects "Cancel" on the confirm message, nothing happens (as is expected). However, when the user selects "OK", the ELSE statement gets invoked. How do I get it under the initial IF statement?

Vincent Puglia
07-10-2001, 06:34 PM
Hi ecojohnson,

My question is which "Else" statement? The confirm code, as posted, is correct (I personally don't use braces if there's only one statement).

If you mean this statement:

<ELSE>
do that


Your problem may have to do with the buttons themselves. Since they are all named the same 'Button', they should probably be referenced as an array. Also, you will note that their first letter is upper case, and you use:
<IF IsDefined ("form.button")>

Finally, 'form' had best be the name of the form itself. And not knowing the IsDefined function, I don't know if you are appending the 'document' (it is a DOM -- document.object.method)

So, my guess is:

<IF IsDefined("document.formName.Button[x]") where formName is the name you give your form (else you can use forms[x]) and x is the index of the button your are testing.

Vinny

ecojohnson
07-10-2001, 07:13 PM
Hi Vincent.

Thanks for your reply.

Well, you are right on all accounts. However, what I failed to supply to you was that all of this is within a CFFORM tag (I am using ColdFusion).

I am thinking that this is the problem. I have to use form instead of the real form name or it won't work (due to using CFFORM). I guess I will try to find the information out using a ColdFusion forum. Thanks for your help!