Announcement

Collapse
No announcement yet.

Tip: setting the initial value of field by code

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

  • Tip: setting the initial value of field by code

    Hi,

    I had a problem with setting the value of a field in the OnApplicationInit and OnScriptInit.

    The following didn't work
    Code:
    if(isset($_SESSION['GSM']))
    {
         {phonenumber} = $_SESSION['GSM'];
    }
    Where the session came from a parent dialog.

    So, the tip is as follows. Add the following in the defined value of a field (settings).
    Code:
    ". $_SESSION['GSM'] . "
    However, a even better way is to wrap this into a method (function) so just as an example:

    Code:
    ". $this->setgsmnumber() . "

    Cheers,
    Sparrow
    Last edited by sparrow; 01-14-2015, 12:27 PM.

  • #2
    Most easy way is:

    Code:
    if(isset($_GET['GSM']))
    {
         {phonenumber} = $_GET['GSM'];
    }
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Yes Albert,

      but that didn't work for some reason. Still don't know why but the value didn't get set.

      Cheers
      Sparrow

      Comment


      • #4
        Hi Sparrow, you sample is about $_SESSION which means that the data passed by the url is not seen, it needs to be in the session first. So in your case not the right design.$GET does get the data from the url and works, but it depends on how you call the application. $_GET or $_POST
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          Hi Albert,

          hm... ok I understand your point but can you explain why the $_SESSION['GSM'] does work in the function setgsmnumber ?

          Comment


          • #6
            Originally posted by sparrow View Post
            Hi Albert,

            hm... ok I understand your point but can you explain why the $_SESSION['GSM'] does work in the function setgsmnumber ?
            No. It's virtually impossible to know without looking at the code. You know, I try to help with the php standards I know and I have struggled with $_SESSION first to find out that I needed to use $_POST and $_GET. That's what I share.
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment


            • #7
              Hi Albert,

              No problem. I thank you for your contribution !

              Comment

              Working...
              X