Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Javascript alert box.
Old 11-07-2004, 03:06 PM Javascript alert box.
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Code:
<script language="JavaScript" type="text/javascript"> 
<!--  
function confirm_ex(){ 
if (confirm("Are you sure?")){ 
window.location="http://www.yahoo.com/"
} 
} 
// --> 
</script>
Ok, I have this code, the problem is.. window.location="http://www.yahoo.com/"
Is there a way so it can be like, "continue" or something like that?

Because when deleting a member, I would need the link to be constently changed. Which is able to be done on the function side.

This is the link that sets the box off.
HTML Code:
<a href="#" onClick="confirm_ex();return false;">
THnx
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-07-2004, 03:19 PM
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Code:
<script language="JavaScript" type="text/javascript"> 
<!--  
function confirm_ex(){ 
if (confirm("Are you sure?")){ 
return;
} 
} 
// --> 
</script>
This works, but returns false on both answers. "yes/no"

Are you able to, "return(true);" ???
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Old 11-07-2004, 04:15 PM
labintador's Avatar
Skilled Talker

Posts: 96
Trades: 0
if the user clicks "Yes" then the confirm() function returns true if not then its false.

if (confirm("sure?")({ //true }
else //false

wht do you mean "continue"? can you make it more clearer pls..

peace out
labintador is offline
Reply With Quote
View Public Profile
 
Old 11-07-2004, 05:19 PM
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Ok, they click on the link to delete the user. Which is generate by
PHP Code:
<a href="users.delete.php?ID='.$data[$i]['id'].'"
Then I get the ID and it deletes the user.

Problem is, I cant set that link outside the SQL function.

So, the link
HTML Code:
<a href="#" onClick="confirm_ex();return false;">
is inside the SQL function.

So it would need to be <a href="users.delete.php?ID='.$data[$i]['id'].'" onClick="confirm_ex();return false;">

Problem is. Is that...
Code:
<script language="JavaScript" type="text/javascript"> 
<!--  
function confirm_ex(){ 
if (confirm("Are you sure?")){ 
return;
} 
} 
// --> 
</script>
... returns false, so even if they click yes, it stops, because it returns false.
And if I use "return true;" it returns true, and deletes the user even if they click no/cancel.

So for it to continue, It would need to return true. And return false = stop.


I hope thats indepth anough.
Thanks,
Lothop
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Old 11-07-2004, 05:41 PM
labintador's Avatar
Skilled Talker

Posts: 96
Trades: 0
You can pass the link to a variable

eg. i passed the link to variable url

EDITED

<script language="JavaScript" type="text/javascript">
<!--
function confirm_ex(url){
if (confirm("Are you sure?")){
window.open=(url, target="_self");
}
}
// -->
</script>

<a href="javascript:confirm_ex(users.delete.php?ID='. $data[$i]['id'].');">link</a>


if i got wht you mean, i think this should do the work.

Last edited by labintador; 11-07-2004 at 06:30 PM..
labintador is offline
Reply With Quote
View Public Profile
 
Old 11-07-2004, 08:03 PM
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
No alert box is shown :/

Umm, I might try a different way, what's the code which makes a alert box open (with a yes/no) on page load?
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Old 11-07-2004, 10:23 PM
foobar's Avatar
Extreme Talker

Posts: 225
Trades: 0
Well, it isn't necessarily on a page load, but I think you mean:

alert(msg);
foobar is offline
Reply With Quote
View Public Profile Visit foobar's homepage!
 
Old 11-08-2004, 03:52 AM
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
But that doesn't give a choice of yes or no.

Yes, meaning continue with loading the URL.
No, meaning stop and dont do anything.
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Old 10-01-2005, 04:55 AM
Junior Talker

Posts: 1
Trades: 0
Thanks for the help on this - you were close lothop... all you needed was a return before you called the function in the onclick.

as I am sure you realize a year later
nitwit is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Javascript alert box.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30111 seconds with 12 queries