Announcement

Collapse
No announcement yet.

Has anyone sucessfully updated a variable on the menu header from the main iframe?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Has anyone sucessfully updated a variable on the menu header from the main iframe?

    Hi All,

    I did make a post about this recently, but the suggestions provided did not work, and SC support are also having difficulty providing any workable answer.

    This what I want to do.

    In a control app I have a drop down list. Based on the selection of this list I need to change a text variable on the menu header.

    I have spend two days trying to get it to work, but I am now hopelessly lost. I have tried html and javascript to try and update this variable from the iframe. I have tried parent.document.getElement(s)ByID, byclass, etc, and used .innerhtml to try and set the value but all has failed.

    Also I seem to have found that if I use the javascript on change event it does not allow me to use the ajax on change event properly.

    So has anyone got a fool proof way of changing a variable on the menu header from the apps running in the iframe?

    Thanks

    Tony

  • #2
    Create a Javascript Method/Fuction (i.e. setHeader) with a parameter (i.e. new_titel) and the following code.

    Code:
    $('#lin1_col1',window.parent.document).text(new_titel); //#lin1_col1 is the header variable depending on the header template used for the menu
    Select field onChange Ajax event:

    Code:
    sc_ajax_javascript('setHeader', array('My new Titel'));
    Tadaaa!

    jsb
    Last edited by jsbinca; 10-02-2015, 10:21 AM.

    Comment


    • #3
      Ok may be I'm missing something - but I have created a button on an app that updates a global variable in the menu header.

      Before and after pics:

      Capture1.JPGCapture2.JPG

      Now, the process I use essentially forces the menu app to re-execute AFTER changing the value of a global variable in the menu's header. This will mean that AFTER the header variable is changed, the resultant screen will look like it does after a normal log in (bar the variable change).

      This means that if you wanted a particular app to be displayed after that update (rather than your standard starting app - I'm guessing you want the calling app to be redisplayed perhaps) then you will need to track that manually. Probably by setting a global variable in the calling app, and have some logic in the menu app to check that and start the correct app based on that variable (and then resetting it). I don't show that here, but can expand on that if you wanted more on that.

      Anyway - what I did was this:

      In the menu Layout settings I have a global variable displayed [company] (this variable is actually initialised to my company's name in the login app). See pic (Note: I have a customised HTML template which is why I have more header fields available):

      Capture3.JPG

      Then all I did was create the "testmenu" PHP button in the "calling" app with this code:

      Code:
      [company] = "Changed value!";
      
      sc_redir("menu", "", "_parent");
      I appreciate that is not using Ajax, but I don't see why it cannot be set there the same way.

      Comment


      • #4
        Thanks jsbinca and adz1111,

        Sadly, even though it seemed like simplicity itself, I could not get the javascript option to work. I have no idea what I might have been doing wrong but I tried all sorts to get it going but I failed.

        I eventually used the second method, which I managed to get to work with a few additional "flag" variables, but it does suffer from the visible repaint of the screen which I was trying to avoid, but then again it does now display the correct text in the header.

        Thanks for your help

        Tony

        Comment

        Working...
        X