Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Passing session variable to JavaScript?

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

    Passing session variable to JavaScript?

    Does anyone know how to pass a session variable to JavaScript?

    I would like to do something like this:
    Code:
    var vItem = session.item;
    {grid.Object}._setValue('D','ITEM',vItem);
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com



    #2
    Re: Passing session variable to JavaScript?

    I think you can do something like this:

    Code:
    var vItem = <%A5? session.item %> ;
    {grid.Object}._setValue('D','ITEM',vItem);
    -Steve
    sigpic

    Comment


      #3
      Re: Passing session variable to JavaScript?

      Steve .. That isn't going to work.

      Remember session variables are server side and JavaScript variables are client side.

      You can't execute xbasic from within JavaScript because xbasic only runs on the server.

      Your options are to use an Ajax callback, use a server event ( which I show how to do in this video .... http://screencast.com/t/NGU2MzM4N2Et ) or you can use a technique I described in a previous post about uploading a file that is really similar to an Ajax callback.

      If you are drawing a blank with all of this another option is to store these variables in a table which could be referenced by the user Id or a session variable then you could use the _getValue method to set a Javascript variable.
      Bob Moore


      Comment


        #4
        Re: Passing session variable to JavaScript?

        Originally posted by Bob Moore View Post
        Remember session variables are server side and JavaScript variables are client side.

        You can't execute xbasic from within JavaScript because xbasic only runs on the server.
        Bob,

        You describe the problem exactly. Is there a server event which fires when you push a grid's custom button? That would solve my problem.

        Your options are to use an Ajax callback, use a server event ( which I show how to do in this video .... http://screencast.com/t/NGU2MzM4N2Et ) or you can use a technique I described in a previous post about uploading a file that is really similar to an Ajax callback.
        I'll have to ponder this some more.

        If you are drawing a blank with all of this another option is to store these variables in a table which could be referenced by the user Id or a session variable then you could use the _getValue method to set a Javascript variable.
        That might be a possibility, but that is a really ugly solution. I'll have to think about it some more, as well.

        Alpha really needs to come up with a way to pass session variables to JavaScript within the context of JS Action Scripting (global variables too!).
        ===
        We need this:

        JS Action Scripting<==>session.variable<==>Global Variable
        Peter
        AlphaBase Solutions, LLC

        [email protected]
        https://www.alphabasesolutions.com


        Comment


          #5
          Re: Passing session variable to JavaScript?

          You describe the problem exactly. Is there a server event which fires when you push a grid's custom button? That would solve my problem.
          In this case, just a button click, you will most likely want to use an ajax callback. I'll try to put together a short video on how to do this when I have the time. It's not all that hard to do once you get the basics down.
          Bob Moore


          Comment


            #6
            Re: Passing session variable to JavaScript?

            I was just modifying some stuff Lenny offered up a while ago. Haven't done or tried much of it and my example is not tested.

            Edit: I had an idea this would work, and it does:

            Code:
            <%A5
            dim MyA5Var as c = "This is my A5 Variable."
            %>
            
            <script type="text/javascript">
            var js_var = '<%A5? MyA5Var %>';
            alert(js_var);
            </script>
            Last edited by Steve Workings; 12-24-2009, 12:28 PM.
            -Steve
            sigpic

            Comment


              #7
              Re: Passing session variable to JavaScript?

              Steve,

              That's pretty cool ... I didn't know you could do that!

              So if you need to set the Javascript variable when the original page is generated on the server, then this technique will work.

              However, you must keep in mind that this is working because this A5W page is generated on the server and the Javascript variable is being resolved when the server renders the page.

              So ... if you need to set the Javascript variable after the page is rendered, based on some dynamic data in the grid, then you are still going to have to either issue an Ajax callback or call an A5W page, say in a popuup, to fire the Xbasic code. But the cool thing is that this technique is really simple to implemment in any case for assigning an Xbasic variable to a Javascript variable.

              Thanks for sharing.
              Bob Moore


              Comment


                #8
                Re: Passing session variable to JavaScript?

                WOW ... Steve is really on to something here.

                Forget everything I said about not being able to execute A5 code from within Javascript because this technique works and this is very simple to do.

                I added a button to grid.
                Then added this Javascript to the on-click event:

                js_session_var= '<%A5 ? session.SessionID %>';
                alert(js_session_var);

                This sets the Javascript variable js_session_var to the session.SessionID which is automatically generated by A5 when the page is genereted.

                Very cool and very easy.


                EDIT : Oops I spoke too soon. I started looking at the code in Firebug and what is happening is that this is being resolved when the page is generated. When you look at the page source, you can see this. So we are not executing A5W code when the button is clicked, thus you can't execute A5W (server side code) from within Javascript (which makes sense). Still very cool.
                Last edited by Bob Moore; 12-24-2009, 01:54 PM.
                Bob Moore


                Comment


                  #9
                  Re: Passing session variable to JavaScript?

                  Originally posted by Steve Workings;519832
                  [code
                  <%A5
                  dim MyA5Var as c = "This is my A5 Variable."
                  %>

                  <script type="text/javascript">
                  var js_var = '<%A5? MyA5Var %>';
                  alert(js_var);
                  </script>[/code]
                  Thanks Steve. That is useful to know. Doesn't solve my problem though since I am in the context of Action JS. I'm also avoiding a5w pages as much as possible and trying to stick to grids within a tabbed_ui.
                  Peter
                  AlphaBase Solutions, LLC

                  [email protected]
                  https://www.alphabasesolutions.com


                  Comment


                    #10
                    Re: Passing session variable to JavaScript?

                    Just curious - any resolution on how to pass a session.__protected__variable to be used in an Inline-Javascript?

                    Comment


                      #11
                      Re: Passing session variable to JavaScript?

                      Originally posted by Scholin View Post
                      Just curious - any resolution on how to pass a session.__protected__variable to be used in an Inline-Javascript?
                      Scholin, isn't this the answer:
                      Originally posted by Bob Moore View Post
                      ...
                      I added a button to grid.
                      Then added this Javascript to the on-click event:

                      js_session_var= '<%A5 ? session.SessionID %>';
                      alert(js_session_var);

                      This sets the Javascript variable js_session_var to the session.SessionID which is automatically generated by A5 when the page is genereted.

                      Very cool and very easy.
                      ...
                      Peter
                      AlphaBase Solutions, LLC

                      [email protected]
                      https://www.alphabasesolutions.com


                      Comment


                        #12
                        Re: Passing session variable to JavaScript?

                        I've read and tried variations on this post but I'm still missing something in my needs. I'd like to use the OnSearchRender to set a default search field to session.UserID when the grid is opened from the Tabbed UI. How would I do that?

                        Comment


                          #13
                          Re: Passing session variable to JavaScript?

                          If you are running a grid could you not put the initial value to be a session variable and on update or insert pull the e.datasubmitted.item into the javascript somehow.

                          Just a thought.
                          Chad Brown

                          Comment

                          Working...
                          X