...

View Full Version : Confirm Box



Sagesse
06-04-2004, 05:14 PM
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 ??
:confused:

any insight is appreciated :thumbsup:

jbot
06-04-2004, 05:20 PM
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.

Sagesse
06-04-2004, 05:22 PM
i did try it first.. i've tried looking all over the net but have had no luck..

jbot
06-04-2004, 05:27 PM
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.

Willy Duitt
06-04-2004, 05:57 PM
Actually: "Are you sure you want the color " + color looks correct.
Where's the rest?

Sagesse
06-04-2004, 06:08 PM
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)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Willy Duitt
06-04-2004, 06:19 PM
It is best to use single quotes to delimit a javascript string since most people use double quotes when writing HTML

Try this:


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

jbot
06-04-2004, 06:21 PM
It is best to use single quotes to delimit a javascript string since most people use double quotes when writing HTML

Try this:


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
:rolleyes:

Sagesse
06-04-2004, 06:29 PM
i tried this variation but had no luck

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

Willy Duitt
06-04-2004, 06:37 PM
Oh;

Then use double quotes and escape with a backslash.

Sagesse
06-04-2004, 06:50 PM
no luck :(

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

Willy Duitt
06-04-2004, 07:46 PM
Try this:

I think I messed the delimiters up myself before:


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

glenngv
06-07-2004, 08:28 AM
Try this:

I think I messed the delimiters up myself before:


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>"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum