Alpha Video Training
Results 1 to 3 of 3

Thread: Passing javascript variables between components

  1. #1
    Member
    Real Name
    mike weatherley
    Join Date
    Jan 2011
    Posts
    33

    Default Passing javascript variables between components

    Hi

    I am trying to reference a javascript variable created in one componet in another component but can't figure this out.

    I have a grid with a lookup field that opens a pop up grid. I want to populate a search field in the pop up with the contents of a search field in the first component.

    This is what I'm doing ;

    Component 1
    In the canSearchSubmit javascript system event I have this,
    var myvar = {grid.Object}.getValue('S','SEARCHFIELD'); (I think this populates the variable myvar with the contents of SEARCHFIELD)

    Component 2 (popup grid from lookup field)
    In the onSearchRender javascript system event I have this,
    {Grid.object}.setValue('S','SEARCHFIELD',parent.myvar);

    When I run this I get a javascript error which basically says the variable parrent.myvar does not exist.

    Can anyone help steer me in the right direction ??

    Thanks

  2. #2
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,648

    Default Re: Passing javascript variables between components

    Try removing the "var", so...

    myvar = {grid.Object}.getValue('S','SEARCHFIELD');

    Declaring "var" makes it local.

  3. #3
    Member
    Real Name
    mike weatherley
    Join Date
    Jan 2011
    Posts
    33

    Default Re: Passing javascript variables between components

    Thanks Peter, that did the trick.

    Just when you think you are making progress something simple brings you back down to earth.
    One day I'll grow up to be a real programmer.

Similar Threads

  1. Video : Passing Javascript variables to child windows
    By Bob Moore in forum Application Server Version 10 - Web/Browser Applications
    Replies: 16
    Last Post: 05-10-2011, 08:25 AM
  2. ONCLICK passing parent recnum from xbasic to javascript
    By kimhere in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 04-29-2011, 04:51 AM
  3. Passing session variable to JavaScript?
    By Peter.Greulich in forum Application Server Version 10 - Web/Browser Applications
    Replies: 12
    Last Post: 06-19-2010, 12:47 AM
  4. Passing Session Variable to JavaScript
    By mmaisterrena in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 02-23-2010, 02:12 AM
  5. global variables in dialog components
    By irwincohen in forum Application Server Version 9 - Web/Browser Applications
    Replies: 1
    Last Post: 12-31-2009, 08:24 AM

Bookmarks

Posting Permissions

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