Skip to main content
Inspiring
August 8, 2011
Question

alert then submit

  • August 8, 2011
  • 3 replies
  • 655 views

Hi,

how can i display the alert message then submit the form?  the code below is working fine but if i add the line"{alert("You had selected correct answer D.")}" then it shows error for Object expected.  The reason i do this because i want it to display the meesage to let users know that they had selected the correct answer first then submit the form afteward.  Can anyone please help ?  - thanks

function checkQ() {

chosen = ""
len = document.form26.benchmark.length

for (i = 0; i <len; i++) {
if (document.form26.benchmark.checked) {
chosen = document.form26.benchmark.value
}
}

if (chosen == "D")
{alert("You had selected correct answer D.")}
{
document.getElementById("form26").submit();
}
else {
alert("You chose the wrong value. Please try again.")
}
}

This topic has been closed for replies.

3 replies

Inspiring
August 8, 2011

Don't put the curly braces around the alert function.

Also, this is not a JavaScript forum

Lyndon Patton

405-301-0952

www.ohrc.org

iPhone

Inspiring
August 8, 2011

Hi

This and the last question you posted are specifically JavaScript questions.  You know this is a ColdFusion forum, right?  Not really the right place to be asking this sort of thing.

But anyway.

It looks to me like you've got yor braces screwed up: I suspect you don't want the braces around the alert() statement.

Always make sure to properly indent your code, that way you'll spot this sort of problem immediately.

--

Adam

Inspiring
August 8, 2011

First thing I would do is put a semi-colon after every command.