Jump to content

Confrim box problem


jimfog
 Share

Recommended Posts

The following is a code to recognize time formats such as this: 2:59 a.m. EDTfunction John (){ var range = window.getSelection().toString(); var hourformat=/(\d\d|\d)[:]\d\d\s([A][M]|[a][m]|[a][.][m])/g; var match = range.match(hourformat); if(range==match){alert("You chose(match)");} else{alert("You did not choose a time");}}; JJohn(); The regular expression works fines, what does not work fine is the alert box message .After the user has selected a time, i want an alert message to appear saying:"You chose(time selected goes here)"How am i going to achieve that?The syntax used-as can be seen above-is:{alert("You chose(match)");} It does not workAny suggestions?Summing it up, i want to combine in an alert message both a string and a variable()match.

Link to comment
Share on other sites

"It does not work" is a little vague, but I am assuming it means that the alert shows "You chose (match)" instead of, say "You chose (2:59 a.m. EDT)", correct?You need to take the variable out of the string, like:alert("You chose("+match+")");

Link to comment
Share on other sites

"It does not work" is a little vague, but I am assuming it means that the alert shows "You chose (match)" instead of, say "You chose (2:59 a.m. EDT)", correct?You need to take the variable out of the string, like:alert("You chose("+match+")");
Yes, correct.I will choose your version of the code and tell you if it works.Probably it will work. I tested various code combinations but not yours.
Link to comment
Share on other sites

It worked, thanks.Of course i removed the parentheses, i do not want them.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...