Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes HTML, CSS and JavaScript and the fly likes JS code not working. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JS code not working." Watch "JS code not working." New topic
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: 60785
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 9345
    
    2

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, Certified Scrum Master
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: 41128
    
  45
If you use Firefox, then the Error Console (to be found in the Tools menu) will be very valuable for tracking down JavaScript bugs.


Ping & DNS - my free Android networking tools app
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JS code not working.
 
Similar Threads
dynamic addition of numbers entered in textbox
XSLT problem with javaScript removeAttribute()
i wanna add text field dynamically on onblur even how i can create textbox dynamicall
How can i trace this..
Setting currency problem.