Author
JS code not working.
pramod talekar
Ranch Hand
Joined: Apr 26, 2010
Posts: 316
Hi,
Could you please tell me where exactly I have made mistakes as the following JS code is not working.
Thanks,
Pramod
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56183
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.
[Smart Questions ] [JSP FAQ ] [Books by Bear ] [Bear's FrontMan ] [About Bear ]
pramod talekar
Ranch Hand
Joined: Apr 26, 2010
Posts: 316
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
Joined: Sep 26, 2006
Posts: 8795
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()";
SCJP 1.4, SCWCD 1.4 - Hints for you , SCBCD Hints - Demnachst , SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
pramod talekar
Ranch Hand
Joined: Apr 26, 2010
Posts: 316
Nope Joe.
No change.
Ogeh Ikem
Ranch Hand
Joined: May 13, 2002
Posts: 180
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
Marshal
Joined: Mar 22, 2005
Posts: 35239
posted Jul 17, 2011 03:27:39
0
If you use Firefox, then the Error Console (to be found in the Tools menu) will be very valuable for tracking down JavaScript bugs.
Android apps – ImageJ plugins – Java web charts
pramod talekar
Ranch Hand
Joined: Apr 26, 2010
Posts: 316
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
Joined: May 13, 2002
Posts: 180
replace this code
with this
pramod talekar
Ranch Hand
Joined: Apr 26, 2010
Posts: 316
Thanks Ogeh Ikem
I tried out with both Name.focus() &document.getElementById("Name").focus();
Both ways, it works fine.
Ogeh Ikem
Ranch Hand
Joined: May 13, 2002
Posts: 180
You're welcome.
subject: JS code not working.