aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Javascript function isn't returning a value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Javascript function isn Watch "Javascript function isn New topic
Author

Javascript function isn't returning a value

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

Could anybody please tell me , why this javascript code isn't working .

I am passing a value to a function and expecting a return type from that function .
But nothing is being printed

Please see this code and suggest

Passing a vlue to a function and expecting some appended data to it ,but its not happening here .



Save India From Corruption - Anna Hazare.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Sorry , i forgot to call the function , Modifed cde

Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
a) Where are you returning value?
b) name is global, why are you passing it as an argument, although you can
c) use script tag within HEAD.
d) why new one(name)?

Try this:



-Varun -
(My Blog) - Online Certifications - Webner Solutions
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
C is not true

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Ravi Kiran Va wrote:Hi ,

Could anybody please tell me , why this javascript code isn't working .

I am passing a value to a function and expecting a return type from that function .
But nothing is being printed

Please see this code and suggest

Passing a vlue to a function and expecting some appended data to it ,but its not happening here .



Where are you calling this function?
Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
Eric Pascarello wrote:C is not true


Beg your pardon, but 'not true' is not true as code I pasted works!!
There is one mistake though, change
<script language="text/javascript">
to
<script type="text/javascript">

Writing Javascript code within body tag may be useful in some circumstances but not recommended or required in general.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Varun Chopra wrote:
Eric Pascarello wrote:C is not true


Beg your pardon, but 'not true' is not true as code I pasted works!!


The script is not required to be in the head, so it is not true.

Eric
Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
Eric Pascarello wrote:

The script is not required to be in the head, so it is not true.

Eric


I did not say it is required, I recommended it. Everything is not always required, somethings are just better to follow.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javascript function isn't returning a value