JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old July 9th, 2005, 07:49 AM
byrnesey byrnesey is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 5 byrnesey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 6 m 37 sec
Reputation Power: 0
Help - need to fix javascript delete checker via href

Hi All,

I'd be so grateful if someone could have a quick look at this for me... basically I have a js function called confirm_delete. It does the usual stuff via forms like 'do you really wanna delete this', etc.

It works for me via forms but I'm trying to do the same thing via a href tag and it gives the error message but doesn't move onto the next page... any ideas... code below? I'm sure it's something simple regarding the js function but I'm not au fait with javascript at all so any advice would be a big help.

Thanks in advance, sorry about the php... in a massive rush.


function confirm_delete(ObjectDescription, FormName)
{
ObjectDescription = unescape(ObjectDescription)
alert('You are about to permanently delete "' + ObjectDescription + '"')
if (confirm('Are you sure?'))
{
self.document.forms[FormName].submit()
}
else
{
self.document.forms[FormName].reset()
}
}

HERE'S MY HREF VERSION (NOT WORKING)

$FormName = "edit1.php?TheIDForDelete=".$TheID;
$Arguments = "\"".$StoryHeaderValidate."\",\"".$FormName."\"";
$LISTOFSTORIES .= "<a href=javascript:confirm_delete(".$Arguments.") value=\"Delete\" class='SmallLink'>\n";

BUT VIA FORM IT WORKS PERFECTLY...

print "<td>\n\n<form action=\"blah.php\" method=\"POST\" name=\"delete_$message_id\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"delete_email\">\n";
print "<input type=\"hidden\" name=\"emailtodelete\" value=\"$message_id\">\n";

$subject = rawurlencode($subject); // need to do this else the JS will complain about quotes
print "<input type=\"button\" value=\"Delete\" onClick=\"confirm_delete('$subject', 'delete_$message_id')\">\n";
//print "<input type=\"submit\" value=\"Delete\" >\n";
print "</form>\n\n </td>\n";

Reply With Quote
  #2  
Old July 28th, 2005, 08:42 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 540 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 1 h 44 m 31 sec
Reputation Power: 3
confirm delete in anchor tag

Ths may be more of a PHP problem. Try inserting echo-s to check the var values. eg.:

$Arguments = "\"".$StoryHeaderValidate."\",\"".$FormName."\"";
echo "Arguments: " . $Arguments;
$LISTOFSTORIES .= "<a href=javascript:confirm_delete(".$Arguments.") value=\"Delete\" class='SmallLink'>\n";

Last edited by Mittineague : July 28th, 2005 at 09:33 AM. Reason: the way to solve the problem

Reply With Quote
  #3  
Old July 28th, 2005, 02:09 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
If possible, provide us with the HTML after it's been rendered by the PHP engine.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Help - need to fix javascript delete checker via href


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway