| 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: 204
|
|
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) - Mock Tests
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
C is not true
Eric
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
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: 204
|
|
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: 15357
|
|
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: 204
|
|
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.
|
 |
 |
|
|
subject: Javascript function isn't returning a value
|
|
|