Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13

Thread: Confirm Box

  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Confirm Box

    Hello everyone...

    I've got a question regarding the confirm() call. is it possible to concatenate the message with a variable?

    For example, if I have a drop down list with different colors and the user clicks on submit; I'm looking for the confirm msg to read: "Are you sure you want the color " + color ??


    any insight is appreciated

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what do you think? of course, you can!!

    question back to you: why didn't you try it first and then post if you didn't get it to work.

  • #3
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i did try it first.. i've tried looking all over the net but have had no luck..

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so wot have you written and let's see if we can sort it for you.

    sorry, but the way you wrote your question sounded as tho you were being lazy and not making any effort to code it for yourself.

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually: "Are you sure you want the color " + color looks correct.
    Where's the rest?

  • #6
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jbot
    so wot have you written and let's see if we can sort it for you.

    sorry, but the way you wrote your question sounded as tho you were being lazy and not making any effort to code it for yourself.
    no prob.. I should've been more clear. I writting the script in vb.net
    I apologize also if I'm posting this in wrong section

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    color = dlColorChoices.SelectedItem.Text

    Dim strMsg As String

    strMsg = "<script language=""javascript"">return confirm('Are you sure want the color ' + color);</script>"

    RegisterClientScriptBlock("MsgBox", strMsg)
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It is best to use single quotes to delimit a javascript string since most people use double quotes when writing HTML

    Try this:
    Code:
    strMsg = '<script type="text/javascript">return confirm("Are you sure want the color " + color);</script>';

  • #8
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Willy Duitt
    It is best to use single quotes to delimit a javascript string since most people use double quotes when writing HTML

    Try this:
    Code:
    strMsg = '<script type="text/javascript">return confirm("Are you sure want the color " + color);</script>';
    in VBS a single quote represents a comment, Willy, so he can't do that

  • #9
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i tried this variation but had no luck

    strMsg = "<script type='text/javascript'>return confirm('Are you sure want the color ' + color);</script>"

  • #10
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh;

    Then use double quotes and escape with a backslash.

  • #11
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no luck

    i should just tell my boss to stop being soo picky
    j/k

  • #12
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:

    I think I messed the delimiters up myself before:

    Code:
    strMsg = "<script type=\"text/javascript\">return confirm(\"Are you sure want the color \"" +color+ ");</script>";

  • #13
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Quote Originally Posted by Willy Duitt
    Try this:

    I think I messed the delimiters up myself before:

    Code:
    strMsg = "<script type=\"text/javascript\">return confirm(\"Are you sure want the color \"" +color+ ");</script>";
    That's not how you escape double quotes in VB

    strMsg = "<script type=""text/javascript"">return confirm(""Are you sure want the color " & color & """);</script>"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •