Passing Variable from page to link

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CHouck

    #1

    Passing Variable from page to link

    I have what seems to be a simple problem but I can't figure it out.

    I have a page where I have a link with variables built in which I want
    to pass through the URL so another page can pick the info up.

    My link on the first page (schedule.html) goes to this link:
    disclaimer.html ?customer=23829 7&EventID=190 80

    And I have some Javascript in the page which places the link info into
    the URL:

    <script language="JavaS cript"><!--
    function nextpage(href,s tring) {
    location.href = href + '?' + string;
    }
    </script>

    Now on the (disclaimer.htm l) page I want to receive the info in the URL
    and then have a link that says "I Agree" that contains that dynamic
    info. So the link would look something like this:
    paymentpage.asp x?CustomerId=23 8297EventID=190 8

    The problem is I have a no idea how to GET this info into the link.

    Any help anyone could give me would be greatly appreciated.
    Thanks,
    CHouck

  • mxa@yahoo.com

    #2
    Re: Passing Variable from page to link

    hi,

    you need server side code , do you have access to server ? what
    languages are available?
    parameter passed to a html document via get or post are avalable on
    server side only.

    if you don't have access to the server , you may want to consider
    including or building the next html
    thanks
    Michael

    Comment

    • McKirahan

      #3
      Re: Passing Variable from page to link

      "CHouck" <chouck@voli.co m> wrote in message
      news:1103559936 .690747.146300@ f14g2000cwb.goo glegroups.com.. .[color=blue]
      > I have what seems to be a simple problem but I can't figure it out.
      >
      > I have a page where I have a link with variables built in which I want
      > to pass through the URL so another page can pick the info up.
      >
      > My link on the first page (schedule.html) goes to this link:
      > disclaimer.html ?customer=23829 7&EventID=190 80
      >
      > And I have some Javascript in the page which places the link info into
      > the URL:
      >
      > <script language="JavaS cript"><!--
      > function nextpage(href,s tring) {
      > location.href = href + '?' + string;
      > }
      > </script>
      >
      > Now on the (disclaimer.htm l) page I want to receive the info in the URL
      > and then have a link that says "I Agree" that contains that dynamic
      > info. So the link would look something like this:
      > paymentpage.asp x?CustomerId=23 8297EventID=190 8
      >
      > The problem is I have a no idea how to GET this info into the link.
      >
      > Any help anyone could give me would be greatly appreciated.
      > Thanks,
      > CHouck
      >[/color]

      Will this work for you? Watch for word.wrap.

      <html>
      <head>
      <title>disclaim er.html</title>
      <script type="text/javascript">
      var qstr = location.search ;
      qstr = qstr.replace(/\?/g,"&");
      var pair = qstr.split("&") ;
      var valu = new Array("","");
      for (var i=1; i<pair.length; i++) {
      var parm = pair[i].split("=");
      if (parm[0] = "customer") valu[0] = parm[1];
      if (parm[0] = "EventID") valu[1] = parm[1];
      }
      var page = "paymentpage.as px"
      page += "?CustomerI d=" + valu[0];
      page += "&EventID=" + valu[1];
      function nextpage() {
      location.href = page;
      }
      </script>
      </head>
      <body>
      <a href="javascrip t:nextpage()">I agree</a>
      </body>
      </html>


      Also, if your calling link looks like

      <a
      href="javascrip t:nextpage('htt p://www/','disclaimer.h tml?customer=23 8297&Eve
      ntID=19080')">l ink</a>

      why not remove the function by changing it to

      <a href="http://www/disclaimer.html ?customer=23829 7&EventID=19080 ">link</a>


      Comment

      • McKirahan

        #4
        Re: Passing Variable from page to link

        <mxa@yahoo.co m> wrote in message
        news:1103567571 .547047.170720@ c13g2000cwb.goo glegroups.com.. .[color=blue]
        > hi,
        >
        > you need server side code , do you have access to server ? what
        > languages are available?
        > parameter passed to a html document via get or post are avalable on
        > server side only.[/color]

        Not true. You can access the querystring via location.search on the
        client-side.
        [color=blue]
        > if you don't have access to the server , you may want to consider
        > including or building the next html
        > thanks
        > Michael
        >[/color]


        Comment

        • Börni

          #5
          Re: Passing Variable from page to link

          CHouck wrote:[color=blue]
          > I have what seems to be a simple problem but I can't figure it out.
          >
          > I have a page where I have a link with variables built in which I want
          > to pass through the URL so another page can pick the info up.
          >
          > My link on the first page (schedule.html) goes to this link:
          > disclaimer.html ?customer=23829 7&EventID=190 80
          >
          > And I have some Javascript in the page which places the link info into
          > the URL:
          >
          > <script language="JavaS cript"><!--
          > function nextpage(href,s tring) {
          > location.href = href + '?' + string;
          > }
          > </script>
          >
          > Now on the (disclaimer.htm l) page I want to receive the info in the URL
          > and then have a link that says "I Agree" that contains that dynamic
          > info. So the link would look something like this:
          > paymentpage.asp x?CustomerId=23 8297EventID=190 8
          >
          > The problem is I have a no idea how to GET this info into the link.
          >
          > Any help anyone could give me would be greatly appreciated.
          > Thanks,
          > CHouck
          >[/color]

          Hi,
          i hope i did unterstand right what you want, basically extracting GET
          information from the url.
          the following code snippet extracts everything after the first '=' in
          the url. with a bit of string manipulation you can modify it for your needs.
          And with a little DOM you can then modify the href attribute of the link
          after the page is loaded.

          if (window.locatio n.search != "") {
          var text = window.location .search;
          var exempt =
          text.substring( location.search .indexOf("=")+1 ,location.searc h.length);
          }

          Comment

          • CHouck

            #6
            Re: Passing Variable from page to link

            Thanks everyone for your help. I used McKirahan's (Thanks McKirahan)
            code and everything seems to be working Ok the only thing I 'm having
            problems with now is that when I click on the link that uses
            nextpage(), the URL is passing the EventID to both string parameters.
            So both CustomerID and EventID have the EventId in them. Any ideas...
            Thanks again,
            CHouck

            Comment

            • McKirahan

              #7
              Re: Passing Variable from page to link

              "CHouck" <chouck@voli.co m> wrote in message
              news:1103642149 .232220.124310@ c13g2000cwb.goo glegroups.com.. .[color=blue]
              > Thanks everyone for your help. I used McKirahan's (Thanks McKirahan)
              > code and everything seems to be working Ok the only thing I 'm having
              > problems with now is that when I click on the link that uses
              > nextpage(), the URL is passing the EventID to both string parameters.
              > So both CustomerID and EventID have the EventId in them. Any ideas...
              > Thanks again,
              > CHouck
              >[/color]

              Show us your code, please.


              Comment

              • McKirahan

                #8
                Re: Passing Variable from page to link

                "CHouck" <chouck@voli.co m> wrote in message
                news:1103559936 .690747.146300@ f14g2000cwb.goo glegroups.com.. .[color=blue]
                > I have what seems to be a simple problem but I can't figure it out.
                >
                > I have a page where I have a link with variables built in which I want
                > to pass through the URL so another page can pick the info up.
                >
                > My link on the first page (schedule.html) goes to this link:
                > disclaimer.html ?customer=23829 7&EventID=190 80
                >
                > And I have some Javascript in the page which places the link info into
                > the URL:
                >
                > <script language="JavaS cript"><!--
                > function nextpage(href,s tring) {
                > location.href = href + '?' + string;
                > }
                > </script>
                >
                > Now on the (disclaimer.htm l) page I want to receive the info in the URL
                > and then have a link that says "I Agree" that contains that dynamic
                > info. So the link would look something like this:
                > paymentpage.asp x?CustomerId=23 8297EventID=190 8
                >
                > The problem is I have a no idea how to GET this info into the link.
                >
                > Any help anyone could give me would be greatly appreciated.
                > Thanks,
                > CHouck
                >[/color]

                Do the QueryString "names" ("customer" versus "CustomerId ") have to be
                different between the two pages?

                disclaimer.html ?customer=23829 7&EventID=190 80

                paymentpage.asp x?CustomerId=23 8297EventID=190 8


                If they could be made the same then you could just pass on the entire
                QueryString:

                <html>
                <head>
                <title>disclaim er.html</title>
                <script type="text/javascript">
                function nextpage() {
                location.href = "paymentpage.as px" + location.search ;
                }
                </script>
                </head>
                <body>
                <a href="javascrip t:nextpage()">I agree</a>
                </body>
                </html>

                <a href="disclaime r.html?Customer Id=238297&Event ID=19080">Discl aimer</a>


                Comment

                • CHouck

                  #9
                  Re: Passing Variable from page to link

                  You just answered my question...ever ything works great now.

                  Thank you !!!

                  CHouck

                  BTW, the customer versus customerID thing was my screwup it was just
                  supposed to be customerID for each page. My brains not running on all
                  cylinders these days.

                  Comment

                  Working...