Announcement

Collapse
No announcement yet.

Passing variables to log module from page tamplate

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

    Passing variables to log module from page tamplate

    Hello,

    I am trying to pass a variable to a log module from a form, but it does not pass variable.

    In form,
    Code:
    <input type="text" name="myvar" value="some value">
    In log module,
    Code:
    <MvEVAL EXPR="{ 'passed value = ' $ g.myvar }">
    Output is
    Code:
    passed value =
    variable is not passed to module.

    What would be long in this code?

    Thanks for help
    Last edited by compumate99; 09-17-18, 11:34 AM.
    Daniel Kim, Compu-Mate
    Developer

    #2
    Are you testing the 'g.myvar' to verify it is being populated before you try to write it out?

    Comment


      #3
      The first thing to do is check the source of the page where the hidden input is and make sure the value field has something in it. It could be that you're not getting anything because it's not passing anything.
      M.A.D.* since 1997

      http://www.scotsscripts.com

      *miva application developers

      Comment


        #4
        Yes, before I converted to hidden field, I checked using the following code.

        Code:
        <input type="text" name=name="myvar" value="some value">
        Daniel Kim, Compu-Mate
        Developer

        Comment


          #5
          If I am understanding what you need to do, the value of the variable won't available to the Log module. If the form is on the same page, you'd need to refresh or ajax the page with that form field value as a CGI variable so the log module routine can move/copy it into a Mivascript variable value. It's not available initially because the page renders before your form or variable is processed or populated.

          Scott
          Need to offer Shipping Insurance?
          Interactive Design Solutions https://www.myids.net
          MivaMerchant Business Partner | Certified MivaMerchant Web Developer
          Competitive Rates, Custom Modules and Integrations, Store Integration
          AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
          My T-shirt Collection is mostly MivaCon T-shirts!!

          Comment


            #6
            The first thing I'd recommend is to check that the hidden input is actually inside a form, and also check that the form is actually being submitted. Some Miva pages have a complex design, with multiple forms, and also links and buttons that take you to another page without submitting any form.

            When you used a text box instead of a hidden input, did that work correctly?

            Hope that helps --
            Kent Multer
            Magic Metal Productions
            http://TheMagicM.com
            * Web developer/designer
            * E-commerce and Miva
            * Author, The Official Miva Web Scripting Book -- available on-line:
            http://www.amazon.com/exec/obidos/IS...icmetalproducA

            Comment


              #7
              Hello Kent,

              It was tested with
              Code:
              <input type="text" name=name="myvar" value="some value">
              and it show the value correctly.

              As shown in output result, module is actually fired correctly, which also means the form is submitted.

              Anything else I should check?

              Daniel
              Daniel Kim, Compu-Mate
              Developer

              Comment


                #8
                Another explanation:

                g.myvar hasn't been populated yet because it's still CGI and MvEval doesn't know about CGI variables.

                This is your CGI variable:

                Code:
                 
                 <input type="text" name="myvar" value="some value">
                Try this In your template page:

                Code:
                <mvt:assign name="g.myvar" value="myvar" />

                Then this should work:

                Code:
                 
                 <MvEVAL EXPR="{ 'passed value = ' $ g.myvar }">

                Well, it should work if the value is there when all the mivascript code is rendered, meaning, when the mvt:assign statement executes it will copy the CGI value to the mivascript variable value.
                Need to offer Shipping Insurance?
                Interactive Design Solutions https://www.myids.net
                MivaMerchant Business Partner | Certified MivaMerchant Web Developer
                Competitive Rates, Custom Modules and Integrations, Store Integration
                AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
                My T-shirt Collection is mostly MivaCon T-shirts!!

                Comment


                  #9
                  Originally posted by compumate99 View Post
                  Yes, before I converted to hidden field, I checked using the following code.

                  Code:
                  <input type="text" name=name="myvar" value="some value">
                  I wasn't clear about what I meant. I meant more something like:

                  Code:
                  <MvIF EXPR="{ (len(g.myvar) GT 0 }">
                  <MvEVAL EXPR="{ 'passed value = ' $ g.myvar }">
                  </MvIF>

                  Comment


                    #10
                    If it worked correctly with a text box, it should work correctly with a hidden input, if the hidden input is written in the same place, and has the same name and value. I would take a closer look at the hidden input; maybe it has a missing character or other small error that the compiler isn't catching. Also, if you're doing this on a Miva shopping page, you might check to make sure that there isn't any Javascript or CSS that's affecting the behavior.
                    Kent Multer
                    Magic Metal Productions
                    http://TheMagicM.com
                    * Web developer/designer
                    * E-commerce and Miva
                    * Author, The Official Miva Web Scripting Book -- available on-line:
                    http://www.amazon.com/exec/obidos/IS...icmetalproducA

                    Comment


                      #11
                      Thanks to everybody.

                      Problem solved!

                      It was simple syntax error not detected by the system.

                      Thanks for all your help!
                      Daniel Kim, Compu-Mate
                      Developer

                      Comment

                      Working...
                      X