• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JS code not working.

 
pramod talekar
Ranch Hand
Posts: 347
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Could you please tell me where exactly I have made mistakes as the following JS code is not working.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without giving us any idea where the problem is happening? Or even what the problem is? Please put a little more effort into your post.
 
pramod talekar
Ranch Hand
Posts: 347
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

The code looks good to me, but neither the alert message nor the calculation part takes place if I run it.
Don't know what exactly went wrong.

Apologies for the inconvenience.
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not an expert in this. Try by putting the semicolon inside the double quotes instead of it being outside like you have mentioned in your post onchange="calculatePrice()";
 
pramod talekar
Ranch Hand
Posts: 347
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope Joe.
No change.
 
Ogeh Ikem
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code contains numerous errors. I've spotted only two of them but I'm sure that there are more. For example, the following code

should be

Also, the following code

should be


Like Bear Bibeault said please put a little more effort into your post.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use Firefox, then the Error Console (to be found in the Tools menu) will be very valuable for tracking down JavaScript bugs.
 
pramod talekar
Ranch Hand
Posts: 347
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I've corrected the code and it works fine now.

The only problem I'm facing right now is that if I leave "Name" or "minutesPickup" field empty or invalid, I do get Alert box but then the pointer moves to the next field.
I need to show the pointer in the same field after clicking OK on my Alert box.
I tried changing "onblur" to "onchange" for "Name" field but it didn't work.

Below is the code :
 
Ogeh Ikem
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
replace this code


with this
 
pramod talekar
Ranch Hand
Posts: 347
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ogeh Ikem
I tried out with both Name.focus() &document.getElementById("Name").focus();
Both ways, it works fine.
 
Ogeh Ikem
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic