Solved

Java Script nested call

Posted on 2016-08-08
3
55 Views
Last Modified: 2016-08-08
Hi,

I am learning javascript, trying out the below code, it is not working.
Just wanted to check if the below is feasible.

<html>
<script type = 'text/javascript'>
function call1()
{
this.c = 10;
document.write("call done");
}
function call2()
{
cta = new call1();
//document.write("call2"+cta.c);
}
function execute(){
var abc = new call2();
document.write(abc.cta.c); // can I do like this. if this is wrong any other way.

}
</script>
<body>
<input type = button onclick = "execute()"/>
</body>
</html>
--------------------------------------------
I have created a function "call1". This has a variable "C".
, and created an object for it in another function "call2"
then created a function "execute" to create an object for "call2"
now wanted to access the variable "C" in "call1" through "call2"

Is it possible to do like that?
0
Comment
Question by:sakthikumar
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Gauthier earned 500 total points
ID: 41747311
cta = new call1();
should be
this.cta = new call1();
0
 

Author Closing Comment

by:sakthikumar
ID: 41747358
Excellent Thanks:)
0
 

Author Comment

by:sakthikumar
ID: 41748255
Hi Gauthier,

If you could give me the reason for this, it would be very helpful to me.

Thanks,
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now