• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JS Confirm Box Not Working

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, everyone. I'm working on a JavaScript confirm box for a contact form I have constructed, but it is most definitely not working. (Everything else but the confirm form works, by the way.) I think I need a (a few) fresh pair(s) of eyes to take a look at what I've got so far. I've tried moving var r to the top with everything else, and I've tried keeping it with in its own if statement, but to no avail. I'm sure it's something silly, but I can't seem to put my finger on it. Any assistance is greatly appreciated. Thanks in advance!

 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What jumps out at me is this code:



\n is a character that goes inside a string. For example:
"Thank you for your message! Is the following info correct?\n"
or
lastNameValue + '\n'
 
Anakela Bella
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:What jumps out at me is this code:



\n is a character that goes inside a string. For example:
"Thank you for your message! Is the following info correct?\n"
or
lastNameValue + '\n'


Thanks for your reply, Jeanne! I placed the \ns in side quotes as follows, but the code still is not executing. I'll show you what I've changed:
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any errors in the JavaScript console?

Btw, the document.forms style of notation is very old-fashioned.

And, why aren't you using jQuery to make all this much simpler?
 
Anakela Bella
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Any errors in the JavaScript console?

Btw, the document.forms style of notation is very old-fashioned.

And, why aren't you using jQuery to make all this much simpler?


Hi, Bear. Thank you for your reply! I am actually going very old school and coding this in a text editor. I just used DirtyMarkup to clean up the code, and got several "unclosed string" errors beginning at variable r. It turns out I had either too many or too few quotation marks, and that's why the code wasn't working! Thank you for having me look for errors! The working code is as follows:



As for why I am doing this in JavaScript as opposed to jQuery, I am trying to learn JavaScript before I jump into jQuery for the sake of learning it, I suppose.
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jQuery is a JavaScript library -- not something different from JavaScript. But I understand your approach.
 
Anakela Bella
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:jQuery is a JavaScript library -- not something different from JavaScript. But I understand your approach.


Got it! That's how new I am to this whole thing. Haha... Thanks again!
 
    Bookmark Topic Watch Topic
  • New Topic