Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting information out of other functions

    Hello forum,

    I have 2 functions that should share data on each other. But i have not succeedede to do that. Here is what i tried so far:

    Code:
    Function abc
    {
    number = 2;
    }
    Function xyz
    {
    var object = new abc;
    alert(object.number);
    }
    I do not how to acquire the value of 'number' from function abc and represent it in the alert box in function xyz.
    Please help me

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,466
    Thanks
    3
    Thanked 495 Times in 482 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    function abc()
    {
    this.number = 2;
    }
    function xyz()
    {
    var object = new abc;
    alert(object.number);
    }
    /*]]>*/
    </script></head>
    
    <body onload="xyz();">
    
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey, thanks. but this is not really working and not really the situation i'm in.

    I am working in javascript.js no html file.

    what basicly is going on is this:

    Code:
    function GenereerRapport(alleen_antwoorden)
    { 
    //...code cut out for easier overview
    
    
    		var this.cijfer_aantal_goed_eerste = Math.round((totaal_aantal_goed_eerste / totaal_aantal_beantwoorde_vragen) * 100);
    
    
    //...code cut out for easier overview
    }
    
    function verzend_vraag()
    {
    		
    	var object = new GenereerRapport();
    	
    	alert(object.cijfer_aantal_goed_eerste); //if this works O.K.i am going to remove comment on the line below
    
    	//top.frames.content.frames.tunnel.document.tunnel.goed.value = object.cijfer_aantal_goed_eerste;	
    
    }
    so this is what I did so far. but no success
    Last edited by june; 10-13-2008 at 01:05 PM.

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    you cannot use a dot directly after var.

    thus "var this.cijfer_aantal_goed_eerste" is invalid.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •