Jump to content

Confirm action

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
9 replies to this topic

#1
Guest_Jaan_*

Guest_Jaan_*
  • Guests
I have this script:

[highlight="javascript"]
<script type='text/javascript'>

function confirm_delete(uname,id){

var ask_delete = confirm("Delete user " + uname + "?")
if(ask_delete){

window.location = "index.php?act=members&action=delete&id=" + id;

}

}

</script>
[/highlight]

And here's the function thingy:


confirm_delete('Jaan', '1');


But it don't work.. Maybe someone can tell me what's wrong.
My Firebug says that it's a syntax error.. but I'm not that genius to fix it :D

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Which line has the syntax error?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Guest_Jaan_*

Guest_Jaan_*
  • Guests
I don't know mate..

Posted Image

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I just ran it in FF2 with no problems...
<html>
<head>
<script type='text/javascript'>

function confirm_delete(uname,id){
  var ask_delete = confirm("Delete user " + uname + "?")
  if(ask_delete){
    window.location = "index.php?act=members&action=delete&id=" + id;
  }
}
</script>
</head>
<body>
hiya!
<script type='text/javascript'>
    confirm_delete('Jaan', '1');
</script>
</body>
</html>

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Maybe it's the fact that this line:

var ask_delete = confirm("Delete user " + uname + "?")

.. doesn't end in a semi-colon.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#6
Guest_Jaan_*

Guest_Jaan_*
  • Guests
Ah I decided to use php instead of javascript :D I really don't like javascript :D

#7
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Well, if it still works if you execute it server-side, then fine by me. :)
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#8
Brandon W

Brandon W

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,828 posts
Javascript is quite simple :) I never use to like it, but then I grew to love it :)
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation

Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!


#9
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
And there's always the fact that the syntax is pretty similar, save for variables and the concatenation operator. JavaScript does get annoying when you consider that, unlike PHP, you never know just how it is going to work out when it executes on the client machine.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#10
Brandon W

Brandon W

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,828 posts
Yep. One thing I don't like about JS, it doesn't show errors. It either works or it doesn't, unless you use a JavaScript debugger. Unlike PHP, it shows errors all the time.
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation

Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!