Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

window.confirm box  RSS feed

 
Daniel Martos
Ranch Hand
Posts: 123
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a problem with my program.  Whenever I enter a value in my window.confirm (from my function: quantity, price, or item) it come up as undefined. Any suggestions?



 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66038
140
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "answer" to window.confirm() is returned as the value of the function call. You're not doing anything with it.

Btw, I'd suggest putting the script into a single block rather than one at the beginning and one at the end.
 
Daniel Martos
Ranch Hand
Posts: 123
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:The "answer" to window.confirm() is returned as the value of the function call. You're not doing anything with it.

Btw, I'd suggest putting the script into a single block rather than one at the beginning and one at the end.


I'ved changed it to this, but I think that I'm supposed to create a new function here, but how do I call my placeOrder() function to be used here?

 
Ron McLeod
Saloon Keeper
Posts: 1525
210
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you have a bracket problem in your function.

Your browser's developer tools would have highlighted this.
 
Daniel Martos
Ranch Hand
Posts: 123
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:It looks like you have a bracket problem in your function.

Your browser's developer tools would have highlighted this.


Yes it does appear that I do, but that being said.  placeOrder() is a function that I used to store arrays.  I need to create a window.confirm box that calls that function.
 
Daniel Martos
Ranch Hand
Posts: 123
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:It looks like you have a bracket problem in your function.

Your browser's developer tools would have highlighted this.


W3 School says to do this:



But I need to call my placeOrder() function so that window.confirm box can have that information....
 
Ron McLeod
Saloon Keeper
Posts: 1525
210
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Martos wrote:placeOrder() is a function that I used to store arrays.  I need to create a window.confirm box that calls that function.

That is different than what you are doing now.  In your example, you are calling confirm from within the placeOrder() function.  Are you thinking something like this?:
 
Daniel Martos
Ranch Hand
Posts: 123
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:
Daniel Martos wrote:placeOrder() is a function that I used to store arrays.  I need to create a window.confirm box that calls that function.

That is different than what you are doing now.  In your example, you are calling confirm from within the placeOrder() function.  Are you thinking something like this?:


I guess let me show you the whole thing.  placeOrder() is a function in the heading.

 
Daniel Martos
Ranch Hand
Posts: 123
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:The "answer" to window.confirm() is returned as the value of the function call. You're not doing anything with it.

Btw, I'd suggest putting the script into a single block rather than one at the beginning and one at the end.


Bear,  Can I put my confirm in my original placeOrder function?  How do I do that if I can?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!