Announcement

Collapse
No announcement yet.

Passing external variable to product page

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

    Passing external variable to product page

    Hi all,

    I have a two-stage product ordering system. Stage One (on an external website) gathers detailed information about the visitor (including a generated ID number) and emails this to me. The page then redirects to the appropriate product page of the store, where the visitor completes the order (Stage Two).

    To tie the store order to the visitor-information email, I need to pass the generated ID number to the store page, and ideally set it as the value of the OtherInfo prompt.

    Any way to do this?

    Thanks.

    #2
    At least 2 ways.

    1) Pass the product reference and your ID # in the URL of the Actinic page you're opening. E.g. http://www.mysite.com/acatalog/page....=1234&ID=wowza

    Then in your Actinic pages add a fragment to the onload= in the <BODY ...> tag that calls a JavaScript routine that picks up these values from the URL and then searches the pages FORM vaiables for one named O_<prodref> and sets it's value to the ID parameter in the URL. Don't use getElementById as this only works on IE (Netscape requires that the id="..." tag be present and Actinic only sets the NAME="...").

    2) Instead of picking these up from the URL, set them as JavaScript variables in the calling page, then use an onload routine as above but this one gets its values from the opener property of the window.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thanks Norman. I'll check it out...

      Comment


        #4
        Method 1 worked like a dream.

        In case anyone else needs more... I wrote a js routine which I added to the bottom of Act_ProductBody.html. This checks whether there's a form on the page with a field which has "O_" as the first two characters of the id/name (ie, the "Other info" field) and, if it exists, populates it with the id value which has been passed to the page in the url.

        The basics go something like this...

        var strElement = document.forms[1].elements[3].name;
        // because in my case, it's always the second form on the page and the fourth element I'm looking for. There's a far better way of doing this by looping through the elements in the form to search for the "O_" field (cos it won't be the fourth field for everyone )

        if (String(strElement).substring(0,2) == "O_") {
        strBegin = str.lastIndexOf("=") + 1;
        // this gets the position of the equals sign in the url - which looks something like www.domain.com/pagename.html?ID=12345

        newStr = str.substring(strBegin);
        document.forms[1].elements[3].value = newStr;
        // this puts everything to the right of the equals into the desired form field
        }

        Comment

        Working...
        X